feat(api): guarded single-flight token refresh with one retry#13
Open
leo202000 wants to merge 2 commits into
Open
feat(api): guarded single-flight token refresh with one retry#13leo202000 wants to merge 2 commits into
leo202000 wants to merge 2 commits into
Conversation
Closes mannowell#2. Adds a single-flight refresh guard so concurrent 401 responses share one in-flight /auth/refresh operation, retries the original request exactly once with refreshed credentials (preserving method/headers/body), clears auth state and surfaces a typed AuthenticationError on failure, and avoids retry loops when the refresh endpoint itself returns 401/403. - export AuthenticationError + refreshAuthTokens (single-flight) - request() detects 401, dedupes refresh, retries once, throws typed error - vitest suite: concurrent 401s, successful retry, refresh failure, no-loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2.
Summary
Implements a guarded token refresh flow in frontend/src/services/api.ts so concurrent 401 responses share a single in-flight /auth/refresh operation and the original request is retried exactly once with refreshed credentials.
Changes
Validation
Tests