fix(client): restore 60s cap on Retry-After header#1841
fix(client): restore 60s cap on Retry-After header#1841MukundaKatta wants to merge 1 commit intoopenai:masterfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 654185b544
ℹ️ 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 (and it's a reasonable amount), | ||
| // just do what it says, but otherwise calculate a default | ||
| if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) { |
There was a problem hiding this comment.
Treat zero Retry-After as valid delay
The new guard uses timeoutMillis && ..., which makes a parsed Retry-After: 0 (or retry-after-ms: 0) look invalid and fall back to exponential backoff instead of retrying immediately. This changes behavior for explicit zero-delay responses and contradicts the intended [0, 60s) acceptance range mentioned in the commit message; a server that sends 0 will now incur an unnecessary client-side delay.
Useful? React with 👍 / 👎.
Closes #1840.
A refactor in 583240f dropped the 60s cap on Retry-After parsing, so the SDK now sleeps for whatever the server returns (sometimes 30+ minutes), freezing long-running scripts. Restored the original guard so values outside [0, 60s) fall back to calculated backoff.
Added test in tests/index.test.ts. Couldn't run yarn test locally due to sandbox restrictions; happy to adjust if CI flags anything.