fix: restore 60-second cap on Retry-After header values#1924
Conversation
The Retry-After cap was accidentally removed in a chore commit. This restores it to prevent excessive wait times. Fixes openai#1840 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f63d8ebc9
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (timeoutMillis === undefined) { | ||
| // If the API asks us to wait a certain amount of time (capped at 60 seconds), | ||
| // just do what it says, but otherwise calculate a default | ||
| if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) { |
There was a problem hiding this comment.
Honor the 60-second Retry-After boundary
When the server returns Retry-After: 60 or Retry-After-Ms: 60000, this condition rejects the value and falls back to the default exponential backoff, which can be well under 60 seconds. That means rate-limit responses that ask clients to wait exactly at the documented cap are retried too early instead of respecting the cap boundary.
Useful? React with 👍 / 👎.
Restores the 60-second maximum on Retry-After header values.
Fixes #1840