firebase / firebase/firebase-js-sdk
Web Worker support for persisting multiple tab
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### Operating System
Windows & OSX
### Browser Version
All
### Firebase SDK Version
10.13.0
### Firebase SDK Product:
Firestore
### Describe your project's tooling
Vite, Vue, Web Worker
### Describe the problem
We have a had massive success in regards to performance moving all the Firestore logic to a Web worker, however when we implemented it a year ago the only option for persistence was with `persistentSingleTabManager` and `forceOwnership: true`. A year on and one of the our most common issues are users opening our app in multiple tabs, and then saying things are not working as expected.
It seems currently due to the lack of support of Local Storage in web workers, I propose a simple adapter solution, whereby during the setup of `persistentMultipleTabManager` in the context of a web worker, developers can supply there own local storage adapter, that implements the same interface as the most common `localStorage` in modern browsers.
The adapter could then handle the messaging part/storage that Firestore requires in order to manage multiple tabs.
### Steps and code to reproduce issue
Setup firestore in a Web worker, and use `persistentMultipleTabManager`
by default it attempts to use LocalStorage, but ideally can be supplied with an adapter for LocalStorage that could handle cross window messaging.
Contributor guide
Assessment
This issue has not been assessed yet.