firebase-tools icon indicating copy to clipboard operation
firebase-tools copied to clipboard

Firebase Emulator : Cloud functions not always get triggered on firestore creation

Open haizad opened this issue 1 year ago • 1 comments

[REQUIRED] Version info

node: 20

firebase-functions:^4.7.0

firebase-tools:

firebase-admin:

[REQUIRED] Test case

Deploy function onCreate event

const functions = require("firebase-functions");

exports.purchases = functions.firestore
    .document("adata/{a}/bdata/{b}/cdata/{c}/ddata/{d}")
    .onCreate(async (snap, context) => {

    }

Insert data on Firestore

WriteBatch batch = firestore.batch();
    batch.set(
       firestore.collection('adata/$a/bdata/$b/cdata/$c/ddata').doc(), 
    {'list': FieldValue.arrayUnion(myLists)});

  ....
  //another batch.set
  ...
batch.commit();

[REQUIRED] Steps to reproduce

  1. Run the cloud function script and firestore using firebase emulator.
  2. Begin inserting data to firestore

[REQUIRED] Expected behavior

All document created need to be triggered upon successfully write on Firestore.

[REQUIRED] Actual behavior

Few document were not getting triggered upon successfully write on Firestore. Surprisingly , once a trigger failed, the next document created will be successfully trigger the cloud function.

Were you able to successfully deploy your functions?

Yes

When you ran firebase deploy, did you see any error messages?

No

haizad avatar Feb 20 '24 01:02 haizad

The emulator suite is not part of the firebase-functions SDK. The Firestore team owns the Firestore emulator, not the functions team, so this issue has been unfortunately waiting for the wrong audience.

I'll dig into this a bit to see who the appropriate assignee is.

inlined avatar Mar 05 '24 00:03 inlined