Skip to content

fix(client): bound stalled token requests with a timeout - #137

Merged
nicknisi merged 1 commit into
workos:mainfrom
pcbeingused333:fix/130-refresh-timeout
Nov 9, 2026
Merged

nicknisi merged 1 commit into
workos:mainfrom
pcbeingused333:fix/130-refresh-timeout

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

Fixes #130

A stalled token action keeps the shared refresh promise pending indefinitely, blocking every caller waiting for an access token. Bound both token actions to eight seconds and pass an AbortSignal to cancel the underlying request. The deadline also rejects independently of cancellation, allowing the existing error, retry and finally paths to run even if the action ignores the signal. Clear the deadline whenever the action settles.

Add fake-timer regression coverage for concurrent callers, cancellation, retrying after a timeout, ignoring a late response, and clearing deadlines after success or failure.

Testing and validation

pnpm exec vitest run src/client/tokenStore.spec.ts: 69 pass with the fix; with src/client/tokenStore.ts restored from main, the 4 new tests fail and the other 65 pass. The full suite (312 tests), oxlint, oxfmt --check on the touched files, pnpm run build, the example build and pnpm run build:check all pass on Node 24. The tests mock the server actions, so no real stalled request was exercised; the installed TanStack Start client passes signal through to fetch.

The eight-second limit is the value from #130 and is a constant, so it is easy to change if you prefer another value or want it configurable.

This change was generated with assistance from Codex (AI).

@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Bounds both token actions with an eight-second timeout.

  • Token requests stop waiting after eight seconds.

No actionable issues were found. No tests were run during this review.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Call token action] --> B[Start action and eight-second deadline]
  B --> C{Which settles first?}
  C -->|Action| D[Return token or action error]
  C -->|Deadline| E[Abort request and reject]
  D --> F[Clear deadline]
  E --> F
  F --> G[Run existing success or error path]
  G --> H[Release shared refresh promise]
Loading

Reviews (1) · Last reviewed commit: "fix(client): bound stalled token request..." · Reviewed by Greptile

@nicknisi

nicknisi commented Nov 9, 2026

Copy link
Copy Markdown
Member

THanks!

@nicknisi
nicknisi merged commit 69b3e14 into workos:main Nov 9, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

tokenStore refresh has no timeout, so one hung request blocks every getAccessToken() call

2 participants