You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Jan 23, 2026. It is now read-only.
I feel like this might work, but at the same time, I haven't really thought it though, so I think there are some edge cases where this might be a problem.
This issue is quite old but this still happening in latest version of supabase-js v2. Basically, if you open your app with the Internet off, your session will be killed. This seems extremely critical.
If somebody reads this and have the same problem, I ended up handling session persistence in my side.
Extending the session token time will reduce the chance the user has to refresh the token on initialize and instead will use the auto refresher which handles the issue more gracefully.
It would be nice if we could have a flag like autoInitialize: false so that we can call supabaseClient.initialize() ourselves. If the initialize fails, then we as developers can decide what to do:
Retry
Show an error message telling the user to go online (and catch the exception in sentry.io/bugsnag to debug)
I'll also do some testing on this. Missed this was the case.
I've noticed being logged out more than I suspect to be in my PWA, which can run offline and expects to just be able to do API operations when the connection is reestablished without a new signIn. It uses indexedDB to store write and file data and then when connection is established sends the requests back to Supabase. I use realtime and the connection error "failed to fetch" to go offline mode and then expects to be still have a session (or have token refreshed) when it comes back.
Activity
dshukertjr commentedon Sep 20, 2021
I was thinking if removing session only if status code is present, and if not, retry session recovery here.
I feel like this might work, but at the same time, I haven't really thought it though, so I think there are some edge cases where this might be a problem.
[-]Opening the app while offline deletes user session. [/-][+]Network error remove session data[/+][-]Network error remove session data[/-][+]Network error removes session data[/+]ferrannp commentedon Mar 22, 2023
This issue is quite old but this still happening in latest version of
supabase-js v2. Basically, if you open your app with the Internet off, your session will be killed. This seems extremely critical.If somebody reads this and have the same problem, I ended up handling session persistence in my side.
nahtnam commentedon Apr 23, 2023
I've been having this same issue as well! My temporary solution was to extend the session tokens out to be much longer.
If the
initializefails the user is immediately logged out: https://github.com/supabase/gotrue-js/blob/eb96536a441d21fae75d25ab6de346808c6e6044/src/GoTrueClient.ts#L1166-L1173 (as you pointed out in the issue). Unfortunately, we don't have the ability to control theinitializefunction as it's immediately run oncreateClient. Even theautoRefreshTokenprop won't help.On the other hand, the auto refresher has a nice exponential backoff logic: https://github.com/supabase/gotrue-js/blob/eb96536a441d21fae75d25ab6de346808c6e6044/src/GoTrueClient.ts#L1089
Extending the session token time will reduce the chance the user has to refresh the token on
initializeand instead will use the auto refresher which handles the issue more gracefully.It would be nice if we could have a flag like
autoInitialize: falseso that we can callsupabaseClient.initialize()ourselves. If the initialize fails, then we as developers can decide what to do:GaryAustin1 commentedon Apr 24, 2023
I'll also do some testing on this. Missed this was the case.
I've noticed being logged out more than I suspect to be in my PWA, which can run offline and expects to just be able to do API operations when the connection is reestablished without a new signIn. It uses indexedDB to store write and file data and then when connection is established sends the requests back to Supabase. I use realtime and the connection error "failed to fetch" to go offline mode and then expects to be still have a session (or have token refreshed) when it comes back.