Open mu3 opened 4 years ago
Hi @mu3
The local indexeddb instance is associated with signed in user (or no sign-in), each user will use a different instance to ensure data separation. That is why we need this behavior when persistence is enabled.
From your description, it seems like you are seeing data leaking to other users through local storage? Or is it happen to be data shared across users?
Thanks.
I mean… I expect web app to work like any other native app. When I open up Tweetbot my whole feed is shown immediately since it was cached under my account. It would be unexpected if the user changed while the app was closed. IMO the cache should change in response to the credentials change. Why to verify and wait for something that is not expected to change by itself? I think cache should be returned first (as the data was received under authorized user), and then credentials could be verified and cache handled appropriately. I believe today web apps are mostly used on personal devices like any other apps and not in public libraries. And in addition to that, the web SDK doesn’t enable offline cache by default in order for developer to include “remember me” checkbox during the authorization if needed.
100% agree with all this. In my web app, where I use Auth and Firestore and have enabled persistence, there is always a delay until the UI can show me my logged in status, avatar, etc. I would really imagine that this info would be available immediately, from cache, which is then updated behind the scenes as needed.
The UI now feels too slow when opening the website again after having been logged in before, or when pressing refresh for some reason. All your stuff should be there instantly, but instead it's popping in a split second later, because it's not using the cache. Please change this.
Related comment I made in another issue asking for onAuthStateChanged()
to resolve immediately with the cached auth state: https://github.com/firebase/firebase-js-sdk/issues/4133#issuecomment-1159207679
I've noticed this delay too. It gives firestore a really poor user experience when loading pages. Other libraries could be used to implement another layer of caching, but firestore already has a cache, so why can't we just use it immediately?
Describe the problem
Once signed-in, internally Firestore starts to wait for auth to give its first credential changed event before enabling persistence. The behaviour remains the same even if
firebase.auth()
is completely removed. This verification doesn't actually change anything even if the Firestore rules have changed to return 403 on requested resources: cache is returned as-is, every time.Steps to reproduce / Relevant Code:
firebase.auth().signOut()
makes Firestore act offline-first again. The same as removingIndexedDB > firebaseLocalStorageDb > firebaseLocalStorage > 0
Expected behavior:
When
enablePersistence()
is used alongauth()
, return cache right away. It doesn't seem like a security breach. Especially because cache is returned in any case, just with a delay. I don't feel comfortable usingLocal Storage
workarounds to duplicate data:Describe your environment