feat(web): 429/Retry-After handling in API client (TASK-2026)#882
Merged
Conversation
…bootstrap retry (TASK-2026)
…ry-After (TASK-2026 Codex P1)
…2026 Codex round 2)
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.
What
Adds client-side 429 / rate-limit handling to the web API request wrapper (
web/src/lib/api/client.ts), from the PLAN-1984 Web-UX audit. Previously the client had zero 429 handling despite rate limits being hit fairly consistently.Retry policy
Retry-After: 3) and HTTP-date (Retry-After: Wed, 21 Oct 2026 07:28:00 GMT). Clamped to a 5s ceiling so a hostile/misconfigured huge value can't hang the UI; missing/garbage headers fall back to a 750ms default backoff.PadApiErrorwithcode: 'rate_limited', a "Server busy — please try again in a moment." message, and aretryAfterMsfield. NewisRateLimitError()helper (exported) mirrors theisPlanLimitErroridiom for UI branching.now + Retry-After, pushed forward only). Subsequent idempotent GETs wait out the remaining window (bounded to 5s total) before firing, so independent call sites don't burst a busy server — e.g.localIndex.bootstrap's reconcile 429s, then the collection page immediately fires a follow-updeltaSync. The cooldown expires by wall-clock (not cleared on an unrelated in-flight success, which isn't evidence the limit lifted).Non-429 code paths are unchanged; the cooldown is inert unless a 429 was recently observed.
Test plan
Focused vitest coverage in
client.test.ts: Retry-After parse (seconds / HTTP-date / past-date / missing / garbage / clamp), GET retries exactly once, second 429 surfacesrate_limited, POST does NOT retry,retryAfterMscarried on the error, and the global cooldown makes a follow-up GET wait out the last Retry-After.npm run check(0 errors),npm run build, andnpm run test(138 passing) all green. Two rounds of Codex review — CLEAN.Refs
TASK-2026, PLAN-1984. Complements IDEA-1842 (the separate server-side rate-limit raise) — this is the client-side handling only and does not duplicate it.