-
Notifications
You must be signed in to change notification settings - Fork 900
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
getIdTokenResult() with forceRefresh reruns snapshot listeners that are set to includeMetadataChanges #8686
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Hi @GaurangTandon , thank you for reporting this issue. Could you please confirm if the app also gets refreshed every 7 seconds, and re-call a new Also, what is the security rule for reading documents? Does it have restrictions based on authentication status? Can you add a |
Hi @milaGGL
The webpage is not being reloaded. There is a
I was able to reproduce the issue on a test Firebase project with full read/write permissions. |
Refreshing the snapshot listener on new auth tokens is an intended behaviour to keep the listener "alive" when auth token expired naturally, however, it would have adverse effect on situations where the auth token force refreshed frequently. Unfortunately, there is no work around for it, except not listening to metadata changes, which I assume is required in your case. This issue is added to our backlog , googler please see b/388491409. However, we are under capacity constraints recently, and I cannot provide an ETA for a fix. Sorry for the inconvenience. |
Operating System
macOS Ventura
Environment (if applicable)
Google Chrome 131.0.6778.205 (Official Build)
Firebase SDK Version
10.11.0
Firebase SDK Product(s)
Firestore, Auth
Project Tooling
Default React app
Detailed Problem Description
Context
includeMetadataChanges
set to trueExpected behavior
onSnapshot
listener should only run once when the data loadsActual behavior
snapshot.metadata.fromCache
property toggles between true and false each time the listener runs.Further observation: Setting
forceRefresh
tofalse
ingetIdTokenResult
fixes the issueConclusion: It's not obvious why force refreshing the token changes the metadata on the snapshot causing the listener to rerun.
The behavior might be a bug. Hence I have filed this report.
If it's not a bug, I would like to know if there's a way to skip these unnecessary runs of the snapshot listener.
Steps and code to reproduce issue
The text was updated successfully, but these errors were encountered: