Skip to content

Auth module: Align the session's refresh with the cross-SDK refresh spec - #179

Merged
QuintinWillison merged 4 commits into
mainfrom
auth-refresh-spec-alignment
Nov 9, 2026
Merged

QuintinWillison merged 4 commits into
mainfrom
auth-refresh-spec-alignment

Conversation

@QuintinWillison

Copy link
Copy Markdown
Member

🤖 Claude's Summary

Aligns a Session's refresh with the cross-SDK refresh spec, refresh_session.md as supabase/sdk#316 holds it, in the places the first implementation differed:

  • A refresh the server rejects is a 400 carrying one of refresh_token_not_found, refresh_token_already_used, session_not_found, session_expired, user_banned or validation_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: Refresh returns the remembered rejection without a request. Was: any 4xx other than 429 rejected, the session ended at expiry and Refresh sent the token regardless.
  • A refresh that gets no answer, or a 5xx, 408, 409 or 429, 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 a Retry-After header'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. SessionFromTokens retries its refresh of an expired token the same way, and the local-scope sign-out's refresh stays one attempt. Was: one attempt everywhere.
  • Any other failure, an unlisted 4xx or 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 AccessToken returns after a failed refresh on a kept session (the unexpired token, as before) and how the global sign-out classes a 408, 409 or 429.

… 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 QuintinWillison self-assigned this Nov 4, 2026
@QuintinWillison QuintinWillison added auth Relates to the auth module. sdk-spec-alignment A canonical capability specification has changed in supabase/sdk, to which we need to conform. labels Nov 4, 2026
@QuintinWillison
QuintinWillison marked this pull request as ready for review November 4, 2026 13:37
@QuintinWillison
QuintinWillison removed this pull request from stack #177 November 4, 2026 20:55
Base automatically changed from upgrade-tools-20261103 to main November 4, 2026 20:56
@QuintinWillison
QuintinWillison removed this pull request from stack #181 November 9, 2026 12:21
@QuintinWillison
QuintinWillison merged commit c443eb5 into main Nov 9, 2026
11 checks passed
@QuintinWillison
QuintinWillison deleted the auth-refresh-spec-alignment branch November 9, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Relates to the auth module. sdk-spec-alignment A canonical capability specification has changed in supabase/sdk, to which we need to conform.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant