diff --git a/README.md b/README.md index e94a67a..7cf8b6b 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/common.ts b/src/common.ts index 3877987..d4a2678 100644 --- a/src/common.ts +++ b/src/common.ts @@ -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[][]; diff --git a/src/retry.ts b/src/retry.ts index 7e7b3d6..28ad6d7 100644 --- a/src/retry.ts +++ b/src/retry.ts @@ -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], ]; diff --git a/test/test.retry.ts b/test/test.retry.ts index 7fe9cf1..53a0773 100644 --- a/test/test.retry.ts +++ b/test/test.retry.ts @@ -51,6 +51,7 @@ describe('🛸 retry & exponential backoff', () => { } const expectedStatusCodes = [ [100, 199], + [408, 408], [429, 429], [500, 599], ];