Skip to content

Commit

Permalink
feat(client): retry on 408 Request Timeout (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Sep 14, 2023
1 parent 9db3819 commit 1f98eac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ See [`@azure/openai`](https://www.npmjs.com/package/@azure/openai) for an Azure-
### Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff.
Connection errors (for example, due to a network connectivity problem), 409 Conflict, 429 Rate Limit,
and >=500 Internal errors will all be retried by default.
Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict,
429 Rate Limit, and >=500 Internal errors will all be retried by default.

You can use the `maxRetries` option to configure or disable this:

Expand Down
3 changes: 3 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,9 @@ export abstract class APIClient {
if (shouldRetryHeader === 'true') return true;
if (shouldRetryHeader === 'false') return false;

// Retry on request timeouts.
if (response.status === 408) return true;

// Retry on lock timeouts.
if (response.status === 409) return true;

Expand Down

0 comments on commit 1f98eac

Please sign in to comment.