Skip to content

fix(gateway): cap Retry-After account cooldown at cooldownMax - #986

Open
lanting200 wants to merge 2 commits into
chenyme:mainfrom
lanting200:fix/cap-retry-after-at-cooldown-max
Open

fix(gateway): cap Retry-After account cooldown at cooldownMax#986
lanting200 wants to merge 2 commits into
chenyme:mainfrom
lanting200:fix/cap-retry-after-at-cooldown-max

Conversation

@lanting200

Copy link
Copy Markdown
Contributor

Summary

  • Account cooldowns now honor routing.cooldownMax even when upstream sends a long Retry-After (for example a 504 with a 24h hint).
  • Previously the selector clamped exponential backoff, then overwrote it with the raw Retry-After, so one upstream timeout could freeze a Build account for hours.
  • Adds a unit test that a 24h Retry-After is capped at the configured 1m max.

Test plan

  • go test ./internal/application/gateway -run 'TestMarkFailureCapsRetryAfterAtCooldownMax|TestMarkFailureSoftNetworkCooldown'
  • Enable a Build account, trigger an upstream 504/429 with a long Retry-After, confirm the account leaves cooldown when cooldownMax elapses (not when Retry-After elapses)
  • Set routing.cooldownBase / routing.cooldownMax to 1m in admin settings and confirm the next failure cools for about one minute

Made with Cursor

afeer123 and others added 2 commits August 20, 2026 12:54
Upstream 504/429 Retry-After could freeze an account for hours because
the selector applied it after the max-cooldown clamp. Honor cooldownMax
for both exponential backoff and Retry-After.

Co-authored-by: Cursor <cursoragent@cursor.com>
Official images apply upstream Retry-After after cooldownMax, and Python
cannot parse Go's nanosecond timestamps, so the host clamp skipped the
row. Truncate the fraction to microseconds and rewrite cooldown_until.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

1 participant