fix(auth): apply expiryMargin buffer to hasExpired check in setSession()#1331
Merged
grdsdev merged 2 commits intoguilherme/sdk-784-featauth-add-setsession-support-for-both-access_token-andfrom Mar 25, 2026
Conversation
7 tasks
Co-authored-by: grdsdev <5923044+grdsdev@users.noreply.github.com> Agent-Logs-Url: https://github.com/supabase/supabase-flutter/sessions/80e8e775-47d3-4e08-aa75-07f715c27411
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on optional accessToken parameter in setSession() implementation
fix(auth): apply expiryMargin buffer to hasExpired check in setSession()
Mar 25, 2026
grdsdev
approved these changes
Mar 25, 2026
ee24630
into
guilherme/sdk-784-featauth-add-setsession-support-for-both-access_token-and
15 of 19 checks passed
grdsdev
added a commit
that referenced
this pull request
Mar 30, 2026
…n() (#1331) * Initial plan * fix(auth): apply expiryMargin buffer to hasExpired check in setSession() Co-authored-by: grdsdev <5923044+grdsdev@users.noreply.github.com> Agent-Logs-Url: https://github.com/supabase/supabase-flutter/sessions/80e8e775-47d3-4e08-aa75-07f715c27411 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: grdsdev <5923044+grdsdev@users.noreply.github.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.
setSession()was checking token expiry with no buffer (exp <= now), while the rest of the codebase uses a 30-second pre-expiration margin viaConstants.expiryMargin(as inSession.isExpired). This meant a nearly-expired token could be restored as a valid session, only to trigger an immediate refresh.Change
hasExpiredinsetSession()now includes the same expiry margin, falling back to_callRefreshTokenif the token expires within the margin:🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.