Skip to content

Conversation

@calvinturbo
Copy link
Contributor

This PR contains:

  • a bugfix for Firestore replication not receiving document updates when they move out of replication scope

Describe the problem you have without this PR

Check #7371

Todos

  • two collections test seems to be failing, not sure why
  • don't know if this is the most performant way of handling this, please check
@calvinturbo
Copy link
Contributor Author

calvinturbo commented Oct 13, 2025

Built RxDB with this pull request in my application, seems to resolve issue with needing to call reSync() for updates & also fixes no-updates for documents moving outside of replication scope

@pubkey
Copy link
Owner

pubkey commented Oct 20, 2025

Hi @calvinturbo
The changes look good to me, but it seems that this breaks the CI, please check.

reSync() is needed, because Firestore does not provide information about what data is changed, only that the document has changed or removed
Doc in test was only updating data in Firestore DB but not modifying serverTimestamp causing a failed test when using reSync()
@calvinturbo
Copy link
Contributor Author

calvinturbo commented Oct 23, 2025

Test "two collections" fails for some reason. It returns 5 documents instead of the 10 documents added. Tried all kinds of things but didn't get it working.

Even when putting this in the test itself:

 const q = query(firestoreState.collection);
            onSnapshot(q, (snapshot: { metadata: { hasPendingWrites: any; }; empty: any; docChanges: () => any[]; }) => {
                if (snapshot.metadata.hasPendingWrites || snapshot.empty) {
                    return;
                }

                snapshot.docChanges().forEach((change) => {
                    const data = change.doc.data();
                    if (change.type === "added") {
                        console.log('new');
                        console.log(change.doc.id);
                    }
                    if (change.type === "modified") {
                        console.log('modified');
                        console.log(change.doc.id);
                    }
                    if (change.type === "removed") {
                        console.log('removed');
                        console.log(change.doc.id);
                    }
                });
            });

it still only returns 5 documents via the Firestore onSnapshot after adding the 10 documents via RxDB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants