Skip to content

Respect startup rate limits across both login wake-up paths - #123

Merged
xrpbanks merged 2 commits into
mainfrom
fix/login-warmup-rate-limit
Sep 6, 2026
Merged

Respect startup rate limits across both login wake-up paths#123
xrpbanks merged 2 commits into
mainfrom
fix/login-warmup-rate-limit

Conversation

@xrpbanks

@xrpbanks xrpbanks commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Embedded sign-in can stall while the readiness request reports a rate limit. The warmup helper currently retries without pausing when Retry-After is 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:

  • 16 deterministic warmup tests: 7 original retry defects and 3 cancellation cases reproduced failures before their fixes; all 16 pass after them.
  • All 66 frontend regression tests pass in CI on the final commit. After the review fix, the 26 targeted warmup/login/logout tests and the production build also pass locally.
  • Production build, lint, and TypeScript checks pass locally.
  • Only the warmup helper, its tests, and the CI test list change.

The reported live failure includes a plain-text Too Many Requests response. 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.

@xrpbanks
xrpbanks marked this pull request as ready for review September 6, 2026 11:44
Copilot AI lite review requested due to automatic review settings September 6, 2026 11:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 429 responses even when Retry-After is 0 or invalid, and stop shortening longer server-provided cooldowns.
  • Share rate-limit cooldown state between the direct backend wake URL and the same-origin /api/backend warmup 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.

Comment thread frontend/lib/backendRequest.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@xrpbanks
xrpbanks merged commit ffa4178 into main Sep 6, 2026
5 checks passed
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.

2 participants