I have simple web app with firestore, that has one onSnapshot
listener. I have enabled persistence and always check if data from the listener comes from server or local cache. Everything works as expected (fromCache
metadata is always true, if there were no changes to documents) when I have my application opened in one browser tab. But when I call onSnapshot from multiple tabs, fromCache
metadata is always false in all tabs.
I always call
firebaseApp.firestore().enablePersistence({synchronizeTabs: true})
right after
firebase.initializeApp()
With synchronizeTabs: true
I would expect all tabs to get data from local cache, but this expected behaviour returns only after closing all other tabs except one (doesn't matter which one)
What's the reason to synchronize persistence between browser tabs, but get the data from server anyway? Or is it just confusing metadata?
I use chrome 91.0.4472.124
and "firebase": "^8.7.1"