Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,9 @@ export class OpenAI {
}
}

// If the API asks us to wait a certain amount of time, just do what it
// says, but otherwise calculate a default
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)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

const maxRetries = options.maxRetries ?? this.maxRetries;
timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
}
Expand Down