Skip to content

Incompatible with firebase-functions 6.0: TypeError when starting emulator #7637

Closed
firebase/firebase-functions
#1615
@0xDing

Description

@0xDing

[REQUIRED] Environment info

firebase-tools: 13.16.0

Platform: macOS

[REQUIRED] Test case

// Minimal example of a Cloud Function using firebase-functions v6.0
const functions = require('firebase-functions');

exports.helloWorld = functions.https.onRequest((request, response) => {
  response.send("Hello from Firebase!");
});

[REQUIRED] Steps to reproduce

  1. Install the latest version of firebase-tools
  2. Create a new Firebase project and initialize Cloud Functions
  3. Update firebase-functions to version 6.0 in package.json
  4. Implement a simple Cloud Function as shown in the test case
  5. Run firebase emulators:start

[REQUIRED] Expected behavior

The Firebase emulator should start successfully and the Cloud Function should be available for testing.

[REQUIRED] Actual behavior

The emulator fails to start, throwing the following error:

⚠  TypeError: Cannot read properties of undefined (reading 'setEmulatedAdminApp')
    at Proxy.<anonymous> (/Users/ding/.volta/tools/image/packages/firebase-tools/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:363:34)

It appears that firebase-tools is not compatible with the latest firebase-functions 6.0. The error suggests that setEmulatedAdminApp is being called on an undefined object, which is likely due to changes in the structure of firebase-functions 6.0.

The issue seems to be related to the fact that setEmulatedAdminApp is specific to firebase-functions/v1, while version 6.0 defaults to v2 of Cloud Functions. For v1 functionality, it now requires a separate import from "firebase-functions/v1".

Additional context

This incompatibility is preventing developers from using the latest version of firebase-functions with the current firebase-tools. A potential workaround might be to explicitly import from "firebase-functions/v1" when using v1 features, but this doesn't solve the underlying compatibility issue with firebase-tools.

It would be greatly appreciated if the Firebase team could investigate this compatibility issue and provide guidance on how to use firebase-tools with firebase-functions 6.0, or update firebase-tools to properly support the new version structure of firebase-functions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions