Respect startup rate limits across both login wake-up paths - #123
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new cooldown sleep path does not currently respond promptly to AbortSignal cancellation during potentially long rate-limit cooldowns, which can delay cancellation for the full warmup window.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates the frontend backend-warmup helper to respect 429 Retry-After more safely during login startup by enforcing a minimum pause, honoring longer server cooldowns within the overall warmup deadline, and sharing cooldown state across the direct and same-origin wake-up paths to avoid double-retrying against the same backend.
Changes:
- Enforce a minimum 30s delay on
429responses even whenRetry-Afteris0or invalid, and stop shortening longer server-provided cooldowns. - Share rate-limit cooldown state between the direct backend wake URL and the same-origin
/api/backendwarmup path. - Add deterministic warmup rate-limit tests and include them in CI.
File summaries
| File | Description |
|---|---|
| tools/tests/backend_warmup_rate_limit.test.mjs | Adds deterministic tests covering Retry-After parsing, minimum cooldowns, and shared cooldown across wake-up paths. |
| frontend/lib/backendRequest.ts | Implements shared cooldown handling and updated Retry-After backoff behavior in warmup logic. |
| .github/workflows/ci.yml | Adds the new warmup rate-limit test to the CI test list. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrowly scoped to warmup retry behavior, are covered by comprehensive deterministic tests (including cancellation and shared-cooldown cases), and integrate cleanly into CI.
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 0 new
- Review effort level: Lite
Embedded sign-in can stall while the readiness request reports a rate limit. The warmup helper currently retries without pausing when
Retry-Afteris zero, caps longer server cooldowns at 60 seconds, and lets its two paths retry independently against the same backend.This change gives rate-limited warmup attempts a minimum 30-second pause, preserves longer server-provided cooldowns within the existing overall deadline, and shares the cooldown between the public and same-origin wake-up paths. A cooldown beyond the remaining window ends the attempt without another request. Both the regular retry pause and the shared cooldown stop immediately on cancellation; a successful route also clears the losing route's timer. Ordinary startup backoff and the authentication protocol remain unchanged.
Validation:
The reported live failure includes a plain-text
Too Many Requestsresponse. Its response headers were not captured, so these reproduced retry defects are not claimed to be the sole cause of the live incident. Joint WordPress/CalorieApp sign-in remains unverified. This PR does not change hosting configuration, WordPress files, secrets, or database state; deployment requires a separate decision.