-
Notifications
You must be signed in to change notification settings - Fork 895
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
AppCheck token refresh is triggering permission-denied
in existing Firestore snapshot listeners
#7116
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
@harrisonlo - Can you confirm the |
@dwyfrequency The app is using reCAPTCHA Enterprise and yes it is indeed 1 hour. I don't remember changing this, but should I change it to 1 day? |
Here is a new set of error logs: At 20:12, all 5 snapshot listeners trigger the error. Then you can see the 55 minutes intervals. The snapshot pair at row 6 & 7 is also part of the first 5, so the interval there is about 16 minutes only. Interestingly, here are the console logs from the browser:
|
So if I'm understanding correctly, the computer was asleep (closed) for a while, and when you opened it, you saw these console logs, and nothing before it (from while the computer was asleep)? The reason I'm asking is that a
The only thing that should trigger the throttle should be a 403 or 404 error, which means it would have to be connected to the internet, reach the App Check endpoint, and get one of those errors in response. One guess is that this happened while the computer was asleep, and reCAPTCHA fails somehow if the computer is closed, which causes a 403 error when the SDK tries to exchange the reCAPTCHA token with the App Check endpoint, which causes you to be locked out for a day. Do all these examples occur when the computer is closed, or asleep? Or does it also happen when the computer is open and active the whole time? Edit: Also, did you ever see any errors that say "ReCAPTCHA error."? |
May be same issue as #6708 |
Possible solution: We currently only clear the throttle if there's a successful request:
Instead, maybe we should clear it if there's any other error other than a FETCH_STATUS_ERROR (right before line 97) - or clear it if it's a set of specific errors (including FETCH_NETWORK_ERROR). |
Update: the errors went away after setting the token time to live to 1 day. I don't know if the underlying issue is solved tho. Back when I created this issue, the errors happened during usage, not when the computer is closed. I also don't remember seeing any ReCAPTCHA error. |
Hi @harrisonlo, In April we changed the behavior a bit to better deal with these sorts of errors. Could you update your Firebase dependency to see if this issue is still a problem? Thanks! |
Hey @harrisonlo. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
Since there haven't been any recent updates here, I am going to close this issue. @harrisonlo if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this. |
Describe your environment
Describe the problem
When the browser tab is left open for an extended period of time, the app regularly detects
permission-denied
errors from Firestore snapshot listeners. Here is a screenshot in which you may see a pattern:These errors mostly have a 55 minutes interval, which I suspect is due to the token refresh from AppCheck, which I recently enforced. There are 5~7 active snapshot listeners in the app, not all of them trigger this all the time. As you can see in the screenshot, only a pair of them consistently did. However, all of them erroneously triggered the error at one point.
Depending on the app logic, it sometimes breaks the app. i.e. when you don't have permission, you can't access a document.
Also I should clarify, the user does have permission. Refreshing always solves the permission issue.
Steps to reproduce:
Enforce Firestore AppCheck in the Firebase console, then open a page with a Firestore listener for 55 minutes to an hour until the AppCheck token refreshes.
Relevant Code:
This error is captured in the third argument of the Firestore
onSnapshot
hook.The text was updated successfully, but these errors were encountered: