retry-axios
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -40,2 +40,6 @@ import { AxiosError, AxiosInstance, AxiosRequestConfig } from 'axios'; | ||
shouldRetry?: (err: AxiosError) => boolean; | ||
/** | ||
* When there is no response, the number of retries to attempt. Defaults to 2. | ||
*/ | ||
noResponseRetries?: number; | ||
} | ||
@@ -42,0 +46,0 @@ export declare type RaxConfig = { |
@@ -37,2 +37,6 @@ "use strict"; | ||
config.httpMethodsToRetry || ['GET', 'HEAD', 'PUT', 'OPTIONS', 'DELETE']; | ||
config.noResponseRetries = (config.noResponseRetries === undefined || | ||
config.noResponseRetries === null) ? | ||
2 : | ||
config.noResponseRetries; | ||
// If this wasn't in the list of status codes where we want | ||
@@ -86,2 +90,7 @@ // to automatically retry, return. | ||
} | ||
// Check if this error has no response (ETIMEDOUT, ENOTFOUND, etc) | ||
if (!err.response && | ||
((config.currentRetryAttempt || 0) >= config.noResponseRetries)) { | ||
return false; | ||
} | ||
// Only retry with configured HttpMethods. | ||
@@ -88,0 +97,0 @@ if (!err.config.method || |
{ | ||
"name": "retry-axios", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Retry HTTP requests with Axios.", | ||
@@ -5,0 +5,0 @@ "main": "./build/src/index.js", |
@@ -52,5 +52,8 @@ # retry-axios | ||
raxConfig: { | ||
// Retry 3 times before giving up. Defaults to 3. | ||
// Retry 3 times on requests that return a response (500, etc) before giving up. Defaults to 3. | ||
retry: 3, | ||
// Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc). | ||
noResponseRetries: 2, | ||
// Milliseconds to delay at first. Defaults to 100. | ||
@@ -57,0 +60,0 @@ retryDelay: 100, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27644
197
118