Promises returned by doc().get() sometimes stop getting resolved if persistence is enabled (original) (raw)

Describe your environment

Describe the problem

In our app, we've discovered that sometimes when you request documents from a collection in quick succession, the documents just stop loading. The promises returned by SDK (doc(id).get()) just stop getting resolved, then callback never fires, and neither does catch.

Steps to reproduce:

It is a very hard to replicate issue.

We've discovered that the issue happens only with enabled persistence. So we've created a codesandbox to reproduce.

https://xqwkf.csb.app

You will see a button. This button loads a document from a collection, using a random id. Normally, when you click it once, you will see 2 logs in the console - START, meaning request is started, and FINISH, meaning promise is resolved, and the document is retrieved.

However, if you click this button fast enough, the promises stop getting resolved. You will only see START logs, and no FINISH logs.

It replicates only sometimes. We couldn't pin point the exact 100% steps to reproduce. So I'm attaching a gist where you see the logs from the console (Firestore debug logs included) from one of the successful attempts. You can search for "POI:" in that gist to find the place when it stopped working. Gist: https://gist.github.com/optimistiks/6176952eff312fba981c0c8d90254639

Relevant Code:

https://codesandbox.io/s/busy-mendel-xqwkf. The code for the above example. Note that it won't work in the codesandbox preview, you need to open it in a separate tab using this link https://xqwkf.csb.app.