Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Worker support for persisting multiple tab #8438

Open
u12206050 opened this issue Aug 19, 2024 · 1 comment
Open

Web Worker support for persisting multiple tab #8438

u12206050 opened this issue Aug 19, 2024 · 1 comment

Comments

@u12206050
Copy link

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.

@u12206050 u12206050 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Aug 19, 2024
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Aug 19, 2024
@ehsannas
Copy link
Contributor

Hi @u12206050 ! Thanks for your proposal. I brought it up with the team, and we think it'd be a useful addition.

While we can't prioritize adding this feature right now, we always welcome contributions. I think you'd need to pass in your adapter instance somewhere (such as PersistentCacheSettings), and then use your adapter here.

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

No branches or pull requests

4 participants