-
Notifications
You must be signed in to change notification settings - Fork 885
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
User hasn't closed app for a couple of days results in INTERNAL ASSERTION FAILED: Unexpected state
#8383
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
INTERNAL ASSERTION FAILED: Unexpected state
@jbalidiong Do you have a status update on this? Do you maybe know if someone is having a look into this? |
Hi @TimmNL , Just want to double check, if removing force token refresh, the multi tab is working? Could you please provide a log so that we can see what happened before internal assertion failed? It would also be helpful if you can have a constant repo way since it is hard to debug if the only way triggering it is waiting for a couple of days. The team thinks what is going on here might relate to two issues.
Could you please share more of "breaks local persistence over multiple tabs"? It is referring to, for example you have one tab open and it listen from cache, the another tab is modifying the cache but the first tab didn't get update? |
Hi @cherylEnkidu, Thanks for the response! You are correct; removing the following code snippet did indeed make it work in multiple tabs: onAuthStateChanged(auth, async (user) => {
if (import.meta.env.MODE === 'development') {
// eslint-disable-next-line no-console -- only show on dev
console.log('user state changed', user?.uid);
}
await user?.getIdToken(true);
if (import.meta.env.MODE === 'development') {
// eslint-disable-next-line no-console -- only show on dev
console.log('user state changed - getIdToken called', user?.uid);
}
}); By "breaks local persistence over multiple tabs," I mean that after opening a second tab with the same site, the first tab starts throwing the same error as shown above. The newly opened tab, however, works fine and doesn't show any problems. I've executed the following steps, this time running with my emulator: Steps
When I check the emulator logs, it states that some requests have come in with request.auth having the value null. The reason for adding this was to ensure the user existed when executing a query, as occasionally, after having the app open for a couple of days, it would show that auth.currentUser.uid was null. My idea was that requesting a new token with user?.getIdToken(true) when the auth state changed would fetch a new token for the user, resolving the issue. However, the problem persists, and users still do not receive any data after a few days. |
@cherylEnkidu or @jbalidiong, Do you have an update on this? I'm still stuck on it and I'm getting more complains from users about it. Thanks! |
@cherylEnkidu and @jbalidiong , Today I got a different error message while working on a hosted version of the project. I got the following, in which the user is authorized but I get |
Hi @TimmNL , The team receives some bug report ticket related to exception throw from AsyncQueue. We are working on investigation to see whether they are related to the same root cause. In the meantime while I am working on reproducing this issue, could you please provide the stack trace of the crash? |
@cherylEnkidu Is the strack-trace I sent of any help? Do you have any update on what could be going on here and how I could fix it? Or might you have a work-around for the time being? |
@cherylEnkidu or @jbalidiong, Do you have any updates on the issue and do the stack-traces provide any information? |
Hi @TimmNL , Thank you for providing the stack trace. The problem you are running into could be related to some under investigation crashes inside While investigating, could you please provide a full debug log just like the developer provided inside the other ticket? |
Operating System
MacOS 14.5
Browser Version
Safari, Chrome, Firefox
Firebase SDK Version
10.12.4
Firebase SDK Product:
AppCheck, Auth, Firestore, Functions
Describe your project's tooling
React with Typescript, Tanstack Query, Vitest and Vite
Describe the problem
I'm trying to create a web-app with offline support, in which the logged in user can create, update and delete todo's. Currently I have implemented firebase auth, firestore, firebase appCheck and firebase functions to trigger some cloud functions when the user is online.
The problem I'm having is that users complain that when they have the web-app opened for a couple of days, they eventually get the following error:
INTERNAL ASSERTION FAILED: Unexpected state.
When the user reloads the page, all data is fetched again and everything works fine.
After a little research I found that sometimes the user isn't logged in anymore (firebase/auth's currentUser is null), until they reload the app. It doesn't matter if the user is online or offline, the reload logs the user back in.
To solve this I added some extra code to my auth-handler, which resulted in not being able to share the state between different tabs of the same browser. I'd like to have that functionality back and also a fix of some sort for users that have lost the connection to the app until they reload the app.
Steps and code to reproduce issue
In my app I use singeltons for the app, database and auth to make sure they stay alive, even when the user isn't actively using them. The calls are all done through tanstack query.
My initialization of the firestore app looks like this:
initialization of firebase auth:
initializing firestore database:
Creating a query
Tanstack query:
Place where the error comes shows up:
As seen in the code above, I make use of the
onSnapshot
function to get all the updates.I wonder if I'm the only one with this issue, I could not find an issue related to mine.
Thanks for the help!
The text was updated successfully, but these errors were encountered: