Skip to content

fix(auth): keep polling through transient token-endpoint errors - #13

Merged
TheStreamCode merged 1 commit into
mainfrom
fix/poll-token-transport-errors
Oct 21, 2026
Merged

TheStreamCode merged 1 commit into
mainfrom
fix/poll-token-transport-errors

Conversation

@TheStreamCode

Copy link
Copy Markdown
Owner

Problem

pollToken (src/auth.ts:159-207) turned transport failures into terminal failures: a rejected fetch or a non-JSON body produced body = null, and the else if branch threw login failed: unreadable token response on the first network blip. A user on a flaky network or behind a proxy had the device login aborted mid-flow and had to restart with a new code.

Change

  • Classify transport and parse failures separately: a rejected fetch, an unparseable body, or a body carrying neither an access token nor an OAuth error increments transportFailures and keeps polling.
  • Continue polling until expires_in with the existing interval and slow_down backoff.
  • Abort only on terminal OAuth errors (any string error other than authorization_pending / slow_down).
  • The timeout message now reports how many network errors occurred.

Tests

  • poll survives transient transport failures (fetch rejects twice, then pends, then succeeds)
  • poll keeps polling after unparseable token responses
  • poll still aborts on terminal OAuth errors after a transport blip
  • poll reports transport failures when it times out

Verification

  • npm ci
  • npm run build
  • npm test — 24/24 pass

pollToken treated a rejected fetch or an unparseable token response as a terminal failure and aborted the device login with "unreadable token response" on the first network blip. Classify transport and parse failures separately, keep polling with the existing interval until the device code expires, and abort only on terminal OAuth errors. The timeout message now reports how many network errors occurred.
@TheStreamCode
TheStreamCode merged commit 0f6922b into main Oct 21, 2026
6 checks passed
@TheStreamCode
TheStreamCode deleted the fix/poll-token-transport-errors branch October 21, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant