fix(auth)!: always emit locally stored session as initial session - #1214
Conversation
`.initialSession` used to fire only after attempting to refresh the locally stored session, collapsing "merely expired" and "refresh token invalid" into the same emitted session and delaying every launch on a network round-trip. Remove the `emitLocalSessionAsInitialSession` opt-in flag and make that corrected behavior the only one: the initial session is now emitted immediately, with a best-effort refresh in the background if expired. See #822 (SDK-1489).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe SDK now emits Sequence Diagram(s)sequenceDiagram
participant AuthClient
participant LocalSession
participant TokenRefresh
AuthClient->>LocalSession: Read current session
AuthClient->>AuthClient: Emit initialSession
AuthClient->>TokenRefresh: Refresh expired session asynchronously
Merge Risk: ⚪ Minimal · up to This change makes locally stored sessions available immediately and removes the opt-in configuration, with migration guidance for callers. No actionable merge-blocking risk remains beyond normal checks and review. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Coverage Report for CI Build 31802847872Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.8%) to 85.466%Details
Uncovered Changes
Coverage Regressions95 previously-covered lines in 5 files lost coverage.
Coverage Stats
💛 - Coveralls |
|
The following capabilities are marked
These may have been renamed, removed, or never registered. Please update the capability matrix. |
Avoids creating an unstructured Task on every launch when the locally stored session is still valid.
| // task below, capturing `self` would resurrect this client while it is being deallocated. | ||
| let sessionManager = Dependencies.instances.value[clientID]?.sessionManager | ||
|
|
||
| Dependencies.instances.withValue { $0.removeValue(forKey: clientID) } |
There was a problem hiding this comment.
All these warnings would be de-deplicated if #1207 was merged 😉
Summary
emitLocalSessionAsInitialSession(AuthClient.Configuration,AuthClient.init,SupabaseClientOptions.AuthOptions) — the behavior it used to gate behindtrueis now the only behavior..initialSessionnow always fires immediately with whatever session is stored locally, with a best-effort refresh in the background if it's expired. Previously it fired only after attempting to refresh the local session, collapsing "merely expired" and "refresh token invalid" into the same emitted session and adding a network round-trip delay to every launch.reportIssueruntime warning that told developers to opt in early.V3_MIGRATION.mdentry (compile error for explicitemitLocalSessionAsInitialSession:callers, silent behavior change otherwise — checksession.isExpiredin.initialSessionhandlers).See #822 for the original discussion. Tracked in SDK-1489.
Test plan
swift build --target Auth --target Supabaseswift test --filter AuthTests(240 tests passing)./scripts/spell-check.sh./scripts/format.sh