Skip to content

Commit

Permalink
feat: Retry 408 by Default
Browse files Browse the repository at this point in the history
  • Loading branch information
d-goog committed Apr 9, 2024
1 parent 2d14b3f commit ace8873
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 ace8873

Please sign in to comment.