-
Notifications
You must be signed in to change notification settings - Fork 937
Auth does not persist if app is launched offline (React Native) #7164
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
Comments
Same issue happens to me. I'm using ionic capacitor + angular. I tried different persistence storage options: browserSessionPersistence, indexedDBLocalPersistence, browserLocalPersistence - nothing worked |
I fixed it by using version "firebase": "9.8". |
@thomas-coldwell This comment suggests a solution to the same issue. Can you check if that fixes it? |
Hey @thomas-coldwell. 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. @thomas-coldwell 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. |
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
I have been developing a React Native app that uses the Firebase JS SDK for Auth. It has a simple email + password options setup and I had set this to use persistence as follows:
This works well while I remain fully online and auth is properly persisted between app launches and sessions. However, if I close the app, turn on airplane mode (so no connectivity) and then relaunch the app the auth is no longer persisted and is actually cleared from the async storage entirely.
It is my assumption that in this case the expected behaviour would be that the auth is persisted even if the app is offline (e.g.
auth.currentUser != null
)I have managed to track down the reason for this not persisting the auth and clearing it from async storage:
initializeCurrentUser
it gets the persisted user (which it does have when it launches offline) and then it callsreloadAndSetCurrentUserOrClear
_reloadWithoutSaving
and then makes a request to get the account info.auth/internal-error
and then inreloadAndSetCurrentUserOrClear
this throws causing the user to be immediately cleared and wiped from async storageAgain I'm not too sure what the expected behaviour is in this case where it hits an
auth/internal-error
while initialising. Should it use the persisted auth or clear it? I noticed here you only clear it if the error is not a network request error so maybe it also needs to check the error is not anauth/internal-error
here as well to prevent it clearing?Steps to reproduce:
auth.currentUser
is reported asnull
Relevant Code:
The text was updated successfully, but these errors were encountered: