fix(client): handle missing access token + delayed autoRefresh timer #1
Reference in New Issue
Block a user
Delete Branch "fix/token-refresh-lifecycle"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Three bugs caused hourly logouts in NebulaOS:
getAccessToken()returned null when access token was absent — even if a valid refresh token existed, it bailed immediately instead of attempting a silent refresh.setupAutoRefresh()silently exited whendelay <= 0— when a browser tab was backgrounded and the system timer was throttled/skipped, the proactive refresh window was missed with no recovery.init()guard blocked recovery calls — once_initialized=true, callinginit()again (e.g. from a 401 handler) returnedisAuthenticated()directly without attempting a refresh on expired sessions.Fixes
getAccessToken(): when access token is absent, check for refresh token and attemptrefreshToken()before returning nullsetupAutoRefresh(): whendelay <= 0, callrefreshToken()immediately and re-scheduleinit(): when already initialized but session is expired, attempt silent refresh instead of returning false[IAMClient]debug logs to all key lifecycle eventsImpact
These bugs meant that once an access token expired (1hr TTL), NebulaOS would redirect to /login even though the IAM server session and refresh token were still valid.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.