-
Notifications
You must be signed in to change notification settings - Fork 894
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
BUG: using multi-tab persistence, the queries in the secondary tabs don't report metadata.fromCache=false #8314
BUG: using multi-tab persistence, the queries in the secondary tabs don't report metadata.fromCache=false #8314
Comments
This is NOT a question, but a serious regression introduced in 10.12.1 related to multi-tab persistence... |
Hi @atsjo, thank you for reporting this issue.
Are you trying to switch network condition between online and offline, and expecting to see snapshots with "fromCache: true/false"? I have tried in local test app, and it is working as expected. |
No, but my queries always fetch newer than what's in my local cache, so they usually return 0 elements, with fromCache true, but then return 0 again with fromCache false, to signal data is up to date with backend |
Could you please provide reproduction steps, and what was expected vs what is the current behaviour? |
I'll try to make a repro... I expect to always receive fromCache=false so I know I'm up to date with the server, and I use this to detect if I'm offline or online. This doesn't work in 10.12.2, but DOES work in 10.12.0. |
Hi @milaGGL , I've made a repro and deployed it with different versions of the sdk to different sites: You can just use view source to see the source for these projects, as no bundling is used, and all logic is contained within a couple of lines in index.html. Open the first link in 2 tabs (preferably in separate windows so you see both), and refresh the tabs in turns, and you should see one or both turning red. It takes some tries the first time to trigger this, but I have verified in Chrome/Edge and Firefox on windows, AND on my pixel phone with chrome... This does NOT happen with link nr 2.... I use the fromCache metadata to determine when I'm up to date and connected to the firestore backend, as this is the preferred way of doing that according to the docs.... In my app I open 3 snapshot listeners on startup, and if people have multiple tabs or choose to install it as a pwa, this error is triggered... The firestore db used here allows only reads, and contain no data.... Code used in repro listed below:
|
@atsjo, thank you for the repro, i am looking into the cause. |
Operating System
Latest Windows 10/11 (probably all os)
Browser Version
Latest Chrome/Edge (probably all browsers)
Firebase SDK Version
10.12.2
Firebase SDK Product:
Firestore
Describe your project's tooling
Angular 18 app via newest tooling
Describe the problem
When using multi-tab persistence and realtime listeners via onSnapshot and includeMetadataChanges: true, the queries in secondary tabs never report metadata.fromCache=false, so I cannot detect correct online state for queries when having multiple tabs...
This works fine with 10.12.0, and I tracked down a PR included in 10.12.1 related to a multi-tab issue (#8247) which probably causes this issue. This PR says it fixes that queries in secondary tabs include empty snapshots, but it SHOULD report empty snapshots with changed metadata when includeMetadataChanges=true, or else we cannot determine online state of queries...
Steps and code to reproduce issue
initializeFirestore(getApp(), { localCache: persistentLocalCache({ tabManager: persistentMultipleTabManager() }) });
)The text was updated successfully, but these errors were encountered: