Repository navigation
Auth module: Align the session's refresh with the cross-SDK refresh spec - #179
Merged
Merged
Conversation
… spec, retrying a refresh the server did not judge, ending a rejected session thirty seconds before its token expires and sending a rejected refresh token no more. Co-Authored-By: Claude <noreply@anthropic.com>
QuintinWillison
marked this pull request as ready for review
November 4, 2026 13:37
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Claude's Summary
Aligns a
Session's refresh with the cross-SDK refresh spec,refresh_session.mdas supabase/sdk#316 holds it, in the places the first implementation differed:400carrying one ofrefresh_token_not_found,refresh_token_already_used,session_not_found,session_expired,user_bannedorvalidation_failed. The session ends once thirty seconds or less of its access token remain rather than once it has expired, and no later refresh of the session sends the rejected token again:Refreshreturns the remembered rejection without a request. Was: any4xxother than429rejected, the session ended at expiry andRefreshsent the token regardless.5xx,408,409or429, is retried with the same token inside the one refresh in flight, so every caller waiting on it shares the sequence: 200 milliseconds before the first retry, doubling to thirty seconds, each wait varied by up to a quarter either way and lengthened to aRetry-Afterheader's wait when longer, the retry after the first wait of thirty seconds being the last. The caller's context ending ends the retries with its error.SessionFromTokensretries its refresh of an expired token the same way, and the local-scope sign-out's refresh stays one attempt. Was: one attempt everywhere.4xxor a body that is not a token response, keeps the session and is neither retried nor remembered.Public API is unchanged. The spec is open at supabase/sdk#316, and three points under discussion there are each kept to one place: where the retry sequence stops, what
AccessTokenreturns after a failed refresh on a kept session (the unexpired token, as before) and how the global sign-out classes a408,409or429.