Skip to content

Firestore emulator: snapshotsInSync() fires before all listeners effected by a WriteBatch have fired after enableNetwork() #11625

Backlog

Description

@matteeee

[REQUIRED] Environment info

firebase-tools: 15.37.0

Firestore emulator: cloud-firestore-emulator v1.22.0]

Platform: macOS 26.3, OpenJDK 23.0.1, Node.js v23.11.0

Client SDK: firebase (JS) 13.4.0

Note I originally reproduced this with a flutter client, which is another reason I think this is caused by the emulator.

Platform: macOS

[REQUIRED] Test case

https://github.com/matteeee/firebase-emulator-snapshot-bug

[REQUIRED] Steps to reproduce

  1. Start a firebase emulator
  2. Start ClientA that is listening to QuerySnapshot events for CollectionA and CollectionB. ClientA is also listening to onSnapshotsInSync
  3. Start ClientB
  4. Take ClientA offline by calling disableNetwork()
  5. Have ClientB write to CollectionA and CollectionB in a single batch and commit the batch
  6. Take ClientA online by calling enableNetwork()
  7. Observe that when onSnapshotsInSync fires in ClientA the listener for CollectionA has received the update from ClientB, but the listener for CollectionB has not
  8. Retry against a real Firebase backend and observe that onSnapshotsInSync now only fires after both listeners have received the update from ClientB

[REQUIRED] Expected behavior

As per the Firebase docs: https://firebase.google.com/docs/reference/js/firestore#onsnapshotsinsync_2856f9c

The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if a single server-generated change affects multiple listeners.

So in the above case onSnapshotsInSync should not fire if one of the listeners has received an even that was written as a batch, but other listeners affected by that batch have not received the event yet.

[REQUIRED] Actual behavior

onSnapshotsInSync event fires before all effected listeners have received all events from the batch. Note this only happens when using the emulator.

Activity

  1. changed the title [-]Firestore emulator: snapshotsInSync() fires between the two halves of one WriteBatch after enableNetwork()[/-] [+]Firestore emulator: snapshotsInSync() fires before all listeners effected by a WriteBatch have fired after enableNetwork()[/+] on Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions