Skip to content

fix(auth): keep or clear the session by scope when sign out fails - #1824

Open
irisfield wants to merge 5 commits into
supabase:mainfrom
irisfield:fix/auth-sign-out-scope
Open

irisfield wants to merge 5 commits into
supabase:mainfrom
irisfield:fix/auth-sign-out-scope

Conversation

@irisfield

@irisfield irisfield commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix. Closes #1823.

What is the current behavior?

sign_out() suppresses every AuthApiError and nothing else, so whether a failed logout request clears the local session depends on how the error was classified, not on the scope. With global, a 429 or a JSON 500 clears the session and returns without an error even though the server revoked nothing, while a 503 raises and keeps it. With local, a 503 keeps the session.

What is the new behavior?

I moved the admin.sign_out() call into its own try. A 401, 403, 404 or AuthSessionMissingError counts as already signed out (_is_signed_out_error), and any other error is handled by scope, following supabase/supabase-js#2786:

  • global raises and keeps the session, so the call can be retried or replaced with a local sign out.
  • local removes the session and emits SIGNED_OUT before sending the request, then raises if the request fails. If the access token has expired and the refresh fails with an AuthRetryableError, it still removes the session before raising. A SIGNED_OUT subscriber that raises does not stop the request, and its error is raised after the request is sent.
  • others raises and keeps the session.

The sign_out() docstring now describes each scope.

Additional context

  • global callers that get a 429 or a JSON 500 now see an exception where they used to get a silent success.

@irisfield
irisfield requested a review from o-santi as a code owner October 25, 2026 05:08
@irisfield
irisfield force-pushed the fix/auth-sign-out-scope branch from df50e3b to 43d9b31 Compare October 25, 2026 22:10
@irisfield
irisfield marked this pull request as draft October 26, 2026 21:28
@irisfield
irisfield marked this pull request as ready for review October 29, 2026 00:34
@irisfield

Copy link
Copy Markdown
Contributor Author

@grdsdev When you get a chance, could you take a look at this one? It brings sign_out() in line with supabase/supabase-js#2786, which merged yesterday.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auth: sign_out() silently clears the session when the logout request fails with a JSON error, and keeps it on a 503

1 participant