-
Notifications
You must be signed in to change notification settings - Fork 990
Description
[REQUIRED] Describe your environment
- Operating System version: macOS Catalina 10.15.6
- Browser version: Chrome 85.0.4183.102
- Firebase SDK version: 7.20.0
- Firebase Product: Firestore
[REQUIRED] Describe the problem
Documents deleted with a function don't update the local cache if persistence is enabled.
I am running the firebase emulator. I call a firebase function that deletes an entire collection of documents. The collection disappears from the emulator and when persistence is not enabled, the documents are now gone from query results.
However, when persistence is enabled, Firestore returns those documents when queried, regardless of the specified source. For example, if I specify server as the source, the resulting list of documents still contains those deleted documents. The query metadata indicates that the query results are from the server, but that is not the case. Here is the metadata when source is set to server: { fromCache: false, hasPendingWrites: false }. This is correct, but the collection of returned docs is not.
If I disable persistence, the problem goes away and I am returned the fresh collection - empty as expected.
This is a pretty serious bug that prevents anyone from using Firestore persistence in conjunction with firebase functions that manipulate document collections.
Steps to reproduce:
- Create a firebase function that deletes a collection of documents.
- Enable persistence on the client.
- Fetch collection of documents.
- Call function that deletes the same collection of documents.
- Fetch collection of documents on client with
sourceset toserver. - Notice that the query metadata indicates that query results are from the server
{ fromCache: false, hasPendingWrites: false }but the collection of documents includes all of the documents deleted by the function.
I can't seem to get the latest results from that collection (I expect to receive an empty result) unless I disable persistence, at which point the query result returns an empty list, as expected.