Skip to content

fix: document multi-instance refresh and test replayed rotations - #44

Merged
Bccorb merged 1 commit into
mainfrom
fix/concurrent-refresh-replay
Nov 20, 2026
Merged

Bccorb merged 1 commit into
mainfrom
fix/concurrent-refresh-replay

Conversation

@Bccorb

@Bccorb Bccorb commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Closes #42

Adapter side of M14. The API's refresh replay window (fells-code/seamless-auth-api#613, unreleased) answers concurrent refreshes of one token with the same successor.

Trace: the refresh cookie holds only sub and the API's refreshToken, so two instances given the same R2 write the same refresh cookie. The access cookie carries the API's sessionId. The in-process refresh sharing keeps no state that assumes one winner and its cache is 5 seconds, matching the API default. A 401 (including refresh_token_reused) is never cached, never retried, and clears the cookies. No adapter code change was needed.

  • tests: two adapter instances refreshing in parallel against a mock API that follows the contract both succeed with the same refresh cookie and the same session id (silent and POST /auth/refresh); refresh_token_reused clears cookies with a single upstream call.
  • README: multi-instance deployment, what the window covers, no shared lock needed while request spread and clock skew stay under the window, and that it needs the API release that ships #613.

Checks: ruff check, ruff format --check, mypy, pytest (1088 passed).

Two adapter instances refreshing one token at once each get the API's replayed successor and write the same refresh cookie. No adapter change was needed: the cookie holds only API-supplied fields and refresh_token_reused is already terminal and never retried. Adds tests for both and documents multi-instance deployment against the API release that ships the replay window (seamless-auth-api#613).
@Bccorb
Bccorb force-pushed the fix/concurrent-refresh-replay branch from 7d133d3 to 521728e Compare November 19, 2026 16:42
@Bccorb
Bccorb merged commit c0bab46 into main Nov 20, 2026
7 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 20, 2026
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.

fix(refresh): handle concurrent refreshes across instances

1 participant