firebase / firebase-tools

The Firebase Command Line Tools
MIT License
3.97k stars 917 forks source link

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

Open haizad opened 4 months ago

haizad commented 4 months ago

[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

inlined commented 4 months ago

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.