supabase-flutter icon indicating copy to clipboard operation
supabase-flutter copied to clipboard

Sentry reports AuthException(message: Invalid Refresh Token: Refresh Token Not Found, statusCode: 400)

Open RCVZ opened this issue 9 months ago • 8 comments

Describe the bug Sentry reports a couple of AuthException's All of the reports are on iOS(But those are like 99% of my users)

To Reproduce I have not been able to reproduce this with one of my own devices.

Version: supabase_flutter 2.5.2 supabase 2.1.2 functions_client 2.1.0 gotrue 2.6.1 postgrest 2.1.1 realtime_client 2.0.4 storage_client 2.0.1

Additional context

AuthException(message: Invalid Refresh Token: Refresh Token Not Found, statusCode: 400)
  App                 0x10bb1abd4  GoTrueClient.notifyException (gotrue_client.dart:1206)
  App                 0x10bd5c604  GoTrueClient.recoverSession (gotrue_client.dart:995)
  File "<asynchronous suspension>"
  App                 0x10bd5c32c  SupabaseAuth.recoverSession (supabase_auth.dart:90)
  File "<asynchronous suspension>"
  App                 0x10bb1aa3c  CancelableCompleter.complete.<T> (cancelable_operation.dart:427)

RCVZ avatar May 14 '24 13:05 RCVZ

Duplicate of https://github.com/supabase/supabase-flutter/issues/928

dshukertjr avatar May 14 '24 13:05 dshukertjr

@dshukertjr This is not a duplicate! This error states refresh token not found.

RCVZ avatar May 14 '24 13:05 RCVZ

@RCVZ Next time when you open an issue, you can give the issue a more descriptive name so that it does not look like a duplicate.

dshukertjr avatar May 14 '24 14:05 dshukertjr

Thanks for updating the title!

dshukertjr avatar May 14 '24 23:05 dshukertjr

I've been getting the same issue. User is suddenly logged out of the app and then we get this error message (see below) from Sentry. Screenshot 2024-05-17 at 7 06 32 PM

Donaldd avatar May 18 '24 01:05 Donaldd

I get the same exception when I reopen my web app where I was previously logged in after a longer period of time. I am currently catching this error from the onAuthStateChange Stream but I am not sure how to handle it. When I reload the web-app, the user is logged out and everything works fine.

After digging into the _callRefreshToken method in the GoTrue client I found out that the user is automatically signed out on every AuthException which is not a AuthRetryableFetchException. There is also a test to ensure that the user is logged out when the refresh token is invalid.

In my app, even though I see the **** onAuthStateChange: AuthChangeEvent.signedOut log in my console when the "Invalid Refresh Token" exception is thrown, I don't receive the AuthChangeEvent.signedOut event when listening to the onAuthStateChange, instead I receive the exception and have to handle it in some way. Currently, I sign out the user manually, which seems to work.

@dshukertjr What is the preferred way to handle this exception?

I found some more information about this exception here:

  • https://github.com/supabase/supabase-flutter/pull/879
  • https://github.com/supabase/supabase-flutter/pull/740
  • https://github.com/supabase/gotrue-dart/pull/126

devj3ns avatar Jul 04 '24 06:07 devj3ns

@dshukertjr When is this issue going to be fixed? 3 months have already passed!

RCVZ avatar Jul 25 '24 08:07 RCVZ

@dshukertjr ???

RCVZ avatar Aug 13 '24 18:08 RCVZ