firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

FR: Realtime DB Web Offline Write Persistence and Read Caching

Open HazzMan2409 opened this issue 2 years ago • 2 comments

Operating System

Any

Browser Version

Any

Firebase SDK Version

Any

Firebase SDK Product:

Database

Describe your project's tooling

N/A

Describe the problem

Every other client SDK (iOS, Android and Flutter) supports persisting data offline with the Realtime Database and so this statement in the documentation holds true.

However, the web with the JavaScript SDK has been left behind and swept under the rug:

  • it only supports persisting writes offline by keeping them stored in memory. If the process is closed or the browser reloads everything is gone.
  • reads are not cached at all, not in memory nor on disk. If you go offline, an onValue() that has been invoked before will not run. If you start offline, it's the same result.

I know the Realtime Database is not new and shiny like the FireStore but it should support these use cases and get parity with other SDKs so that the docs hold true.

Steps and code to reproduce issue

Run an onValue() offline or do a set() whilst offline after reloading your browser.

HazzMan2409 avatar Jul 11 '23 20:07 HazzMan2409

I'm experiencing the same issue: using persistentLocalCache on web, the indexedDB will store mutations on existing data items (update and delete)--if you close and reopen a browser it will sync with firestore. However addDoc or setDoc do not appear in the IndexedDB, thus after closing the browser/PWA while offline, the new data is lost.

waseber avatar Aug 29 '23 04:08 waseber

dup of https://github.com/firebase/firebase-js-sdk/issues/17

rockwotj avatar Sep 07 '24 02:09 rockwotj