Description
[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
- Install the latest version of firebase-tools
- Create a new Firebase project and initialize Cloud Functions
- Update firebase-functions to version 6.0 in package.json
- Implement a simple Cloud Function as shown in the test case
- 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.