Can firebase cloud functions emulator invoke triggers with production firestore?

Viewed 1099

I am trying to test a Firebase cloud function on an emulator with real production firestore. When I start up my functions emulator, I get an error i functions[sendPushOnNewMessage]:function ignored because the firestore emulator does not exist or is not running. Interestingly, I can read from firestore (from production data), but firebase emulator refuses to allow these functions to start.

❯ firebase emulators:start --only functions
i  emulators: Starting emulators: functions
i  ui: Emulator UI logging to ui-debug.log
⚠  functions: Your GOOGLE_APPLICATION_CREDENTIALS environment variable points to /Users/.../functions/3afae-a81e699d1cf0.json. Non-emulated services will access production using these credentials. Be careful!
⚠  functions: The Cloud Firestore emulator is not running, so calls to Firestore will affect production.
>  Starting up...
i  functions[createUserRecord]: function ignored because the auth emulator does not exist or is not running.
i  functions[sendPushOnNewMessage]: function ignored because the firestore emulator does not exist or is not running.

Here is how I am using service account to setup (I know this works since I can read documents):

// Service account initialization.
let serviceAccount = require('./3afae-a81e699d1cf0.json');
var initOptions = {}
emulator#set_up_admin_credentials_optional.
if (process.env.FUNCTIONS_EMULATOR) {
  initOptions.credential = admin.credential.cert(serviceAccount)
}
admin.initializeApp(initOptions);
const firestore = admin.firestore();

Example of my trigger function:

exports.sendPushOnNewMessage = functions.firestore.document('chats/{chatID}/messages/{messageID}').onCreate((change, context) => {
    console.log("Trigger called")
}
0 Answers
Related