-
Notifications
You must be signed in to change notification settings - Fork 893
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
Firebase hangs indefinitely when getting token in bad network #8490
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
I get this error in my App "FirebaseError: Missing or insufficient permissions." after two hours of using the app. It seems that the token is not updated automatically. The error is fixed after refreshing the page or look like related to #7590 |
Hi @AmilKey, is your issue related to the original posted issue? If not, could you please open a new one with more information? |
Hi @mrdraz,
My first suggestion is to restructure the way the code tracks if a user is signed in or not. Because the Auth SDK goes through an asynchronous initialization flow, it could be the case that the value for the current user is Therefore I highly recommend adding an Additionally you can await auth.authStateReady() just after initializing Auth. You should then write code within the That might help with some of the flow in sign in. Beyond that I recommend narrowing down which Auth operation is failing within your code. If you can create an SLA call around specific auth token retrieval operations then that would be a helpful way to narrow down the issue that you're encountering. |
Hey @amrdraz. 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! |
Hey there |
If you notice the code does wait and I setup a promise wrapping the subscription (as in the documentation) so I initially try to get the current user if they're present and if they're not then I listen on auth state change until it fires If the user doesn't exist I throw my effect that the user doesn't exist (that's not my error) The issue is that the user does exist but that I listen indefinitely The issue seems more pronounced in the current user getIdToken and if not then onAuthChange get user then getIdToken I see how that SLA (which happens 12.5% ) has a wider surface area But it still happens on 0.3% of specifically signInWithCustomToken where I get a time out
I can rewrite the code with readyState method to check state then continue to use onAuthStateChanged since I didn't log on it but I'm skeptical this is where the issue is (after all most of the time users signup fine) but who knows maybe there is something there and I wasn't aware if this method so I'll give it a try
The auth operation is getIdToken I can't narrow that a bit more for clarity I know for a fact as I mentioned that signInWithCustomToken which is as narrow as I can get doesn't meet the SLA 0.3% of the time |
Hi @amrdraz, Unfortunately I'm not sure how to move forward on our end with this issue. We would need a reproducible test case for us to debug locally. Is there any way you can isolate the problem in a simple test application, reproduce it, and send it to us? |
I'll see if I can do something about that Then try using firebase login on the mobile app 🤷 it is a very strange situation as I mentioned since it happens under some bad network conditions all in all it hasn't been develitating, we just keep getting requests by some users that we keep them logged in and not log them out everytme 😅 |
Ok, thanks. Keep us posted! |
Hey @amrdraz. 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. @amrdraz 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. |
Operating System
Across all OS in this order Android, IOS, Window, OSX, LInux etc..
Environment (if applicable)
Web, PWA and Webview inside react native app
Firebase SDK Version
10.7.2
Firebase SDK Product(s)
Auth
Project Tooling
I have a NextJS app served and built on vercel
I also have a react native app built on Expo.dev, but the login flow happen inside a webview right now
Detailed Problem Description
I had many reports of users not being able to login (I use custom token login) or waiting forever when re visiting the site (when app is refreshing token) most users aren't willing to wait for the full 30 seconds on desktop and the larger 60 seconds on mobile firebase takes to send a network-request error (as seen in code).
So I added an SLA of 10 seconds as I observed that in general when login is working fine it takes less then 2 seconds ( plan on adding a general timer to better check this variability)
The result looks something like this
Which when comparing successful requests on the same first endpoint called, we get a failure rate of 12.5%, it's important to note that in general the internet is working ok, the page did load after all, the JS got downloaded, and other API calls (like the logs ,tracking events and api calls to my server to get the admin token) are working
The issue is with firebase taking too long sometimes to get refresh the token (specifically more then 10 seconds)
Since therumble app has a smaller user base then our main app (thndr app) where we didn't hear many reports of this issue
I figured to also test how often this issue happens (it's only been a day so the code push is still rolling out) but it seems to happen to 0.6% of our sessions that got the code push
With this result I'm tempted to try and move auth on the rumble app to the react native side instead of the web view.
But it doesn't make much sense how bad the web experience would be compared to the app.
I thought maybe it's Egypt we have bad internet, but since thndr.app has a more global user base the issue seems to also occure outside though at a much lesser proportion (which can be attributed to our user base being primarily egyptian)
I'm kind of stumped on how to proceed with therumble.app, I didn't plan on building my own auth 😃
I can try to move to react native, but the issue still happens on desktop (though to a lesser degree of around 7%)
This issue mainly affects refreshing token
The get custom token has fail ratio of ~0.35% (163/(163+4370))
Which is why our users while uncomfortable that they need to login again at least can on average login again... though 0.3% of them get stuck
I can't reproduce the issue in development but as demonstrated it happens daily in production
the data seems to span devices and ip addresses, and even countries
The disproportionate difference in Egypt is likely due to our user base more then it being an Egypt thing and I will say that in general I don't personally experience the issue a lot and many users seem to never experience it, while others seem to get it all the time (likely due to network conditions) when I ran on datadog with the thndr app I also noted the issue spans carriers
Any idea how to proceed
This issue has been ongoing for months but I recently decided to take the time and try to resolve it as we plan on pushing therumble app more
thndr app has been ignoring the issue it seems generally users just logout and login again when stuck
I can't just say it's bad network, because other apis work fine it's google
so I hope you have any ideas
Steps and code to reproduce issue
My get token code is
My get custom token code is
I have an axios interceptor on my API calls like so
When I ran my test on the larger thndr app since we didn't check the SLA before I just had the app log when it took longer then 10, 15, and 20 seconds to get the token.
the rumble app uses axiom for logs
thndr app uses datadog for logs
The text was updated successfully, but these errors were encountered: