Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
0xDing opened this issue Sep 11, 2024 · 10 comments · Fixed by firebase/firebase-functions#1615

Comments

@0xDing
Copy link

0xDing commented Sep 11, 2024

[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.

@sarons
Copy link

sarons commented Sep 12, 2024

have the same issue migrating from v1 to v2. Downgrading firebase-functions 5.0 worked for me

@BostonTerrier-Bon
Copy link

I encountered the same issue with firebase-tools version 13.17.0. Like others, downgrading to firebase-functions version 5.x resolved the issue for me as well.

@aalej
Copy link
Contributor

aalej commented Sep 12, 2024

Hey folks, sorry to hear you encountered this issue, and thanks @0xDing for providing a detailed report! I’m able to reproduce this, let me raise this to our engineering team so they can take a look and investigate. I’ll mark this issue as reproducible.

@c7topher
Copy link

Having this issue also, would love some resolution. I love firebase but.... the number of issues working with it are becoming insurmountable.

@Hibrix-net
Copy link

Same here. Please resolve it.

@Attahirny
Copy link

Also waiting

@Hibrix-net
Copy link

Downgrade to firebase-functions@5.1.1 solved the issue

Downgrading isn't really a solution, as the issue specifically comes from upgrading to v6. The goal is to resolve the problem in v6, not avoid it by reverting to an older version.

taeold added a commit to firebase/firebase-functions that referenced this issue Sep 16, 2024
github-merge-queue bot pushed a commit to firebase/firebase-functions that referenced this issue Sep 16, 2024
* Export 'app' in v2 entrypoint.

Fixes firebase/firebase-tools#7637.

* Add changelog.

* Add comment
@taeold taeold reopened this Sep 16, 2024
@taeold
Copy link
Contributor

taeold commented Sep 16, 2024

Just released 6.0.1 which should address the reported issue.

Please give it a try and let us know!

@BostonTerrier-Bon
Copy link

Thank you for the update! I tested it with firebase-functions version 6.0.1, and the issue seems to be resolved in my environment as well.

@aalej
Copy link
Contributor

aalej commented Sep 17, 2024

Thanks for confirming @BostonTerrier-Bon! I'll go ahead and close this issue, if anyone still encounters this in the future, please leave a comment so that we can re-open.

@aalej aalej closed this as completed Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants