flemingvincent / expo-supabase-starter

A comprehensive starter project for developing React Native and Expo applications with Supabase as the backend.
MIT License
285 stars 44 forks source link

Issues with Session Restoration #56

Closed shashanoid closed 1 month ago

shashanoid commented 1 month ago

supabase-provider.tsx is bound to have issues. After a successful login, close the app. Reload the app and it'll be stuck on splash screen.

While the app is active supabase.auth.onAuthStateChange registers TOKEN_REFRESHED event just fine, however token refresh during a fresh reload will hang indefinitely. Only way around is to reload the app which is stupid.

I've tried restoring the session / refreshing the token manually. None of it works, it just hangs. Session management is screwed.

Steps to reproduce:

  1. Login
  2. Wait 1 hr for token to expire
  3. Open the app (hangs at splash)
  4. Reload and it works fine.
linear[bot] commented 1 month ago

ESS-3 Issues with Session Restoration

flemingvincent commented 1 month ago

Hey @shashanoid,

Thank you for bringing this to my attention! I went ahead and reviewed the supabase-provider.tsx file, making adjustments in line with Supabase's documentation. I've also attempted to reproduce the issue you described, but after the updates, I was unable to replicate it:

https://github.com/user-attachments/assets/3802dc1e-9ce0-4317-b051-5a8a7b8ab3c0

After a successful login, I was able to close the app entirely and reopen without the Splash screen hanging.

If you could, please try pulling these latest changes and see if the issue persists on your end. Let me know if you continue to experience problems, and we can further investigate from there.

Thanks again for your detailed feedback!

shashanoid commented 1 month ago

Hi @flemingvincent thanks for looking into this. I would suggest wait for 1 hr or whatever your JWT expiration time is and then re-opening the app for a logged-in user. Ideally the session should refresh by itself, instead it'll hang on splash screen since it never reaches SplashScreen.hideAsync(); / session object being not available.

I'll try again with your new updates as well. Thanks for the changes!

kendrit commented 1 month ago

@shashanoid Can you confirm this was fixed?

flemingvincent commented 1 month ago

@kendrit I've made additional changes since this issue has been closed: https://github.com/flemingvincent/expo-supabase-starter/blob/1ebbf003ec922aa08097170cc7b5cd3a8f43f22b/config/supabase.ts#L19 This change should finally solve this issue that @shashanoid was experiencing. The change is coming directly from Supabase's User Management App.