Skip to content

Commit

Permalink
feat: Retry 408 by Default (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbankhead committed Apr 9, 2024
1 parent 2d14b3f commit 9331f79
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -132,7 +132,7 @@ interface GaxiosOptions = {
httpMethodsToRetry?: string[];

// The HTTP response status codes that will automatically be retried.
// Defaults to: [[100, 199], [429, 429], [500, 599]]
// Defaults to: [[100, 199], [408, 408], [429, 429], [500, 599]]
statusCodesToRetry?: number[][];

// Function to invoke when a retry attempt is made.
Expand Down
2 changes: 1 addition & 1 deletion src/common.ts
Expand Up @@ -304,7 +304,7 @@ export interface RetryConfig {

/**
* The HTTP response status codes that will automatically be retried.
* Defaults to: [[100, 199], [429, 429], [500, 599]]
* Defaults to: [[100, 199], [408, 408], [429, 429], [500, 599]]
*/
statusCodesToRetry?: number[][];

Expand Down
2 changes: 2 additions & 0 deletions src/retry.ts
Expand Up @@ -42,9 +42,11 @@ export async function getRetryConfig(err: GaxiosError) {
// 2xx - Do not retry (Success)
// 3xx - Do not retry (Redirect)
// 4xx - Do not retry (Client errors)
// 408 - Retry ("Request Timeout")
// 429 - Retry ("Too Many Requests")
// 5xx - Retry (Server errors)
[100, 199],
[408, 408],
[429, 429],
[500, 599],
];
Expand Down
1 change: 1 addition & 0 deletions test/test.retry.ts
Expand Up @@ -51,6 +51,7 @@ describe('🛸 retry & exponential backoff', () => {
}
const expectedStatusCodes = [
[100, 199],
[408, 408],
[429, 429],
[500, 599],
];
Expand Down

0 comments on commit 9331f79

Please sign in to comment.