axios-retry
Advanced tools
Comparing version 3.0.2 to 3.1.0
@@ -8,2 +8,9 @@ # Change Log | ||
## [3.0.3] - 2018-04-26 | ||
### Fixed | ||
- Export isRetryableError for CommonJS | ||
### Added | ||
- Added additional param shouldResetTimeout | ||
## [3.0.2] - 2018-02-09 | ||
@@ -10,0 +17,0 @@ |
@@ -162,2 +162,4 @@ import isRetryAllowed from 'is-retry-allowed'; | ||
* @param {number} [defaultOptions.retries=3] Number of retries | ||
* @param {boolean} [defaultOptions.shouldResetTimeout=false] | ||
* Defines if the timeout should be reset between retries | ||
* @param {Function} [defaultOptions.retryCondition=isNetworkOrIdempotentRequestError] | ||
@@ -186,3 +188,4 @@ * A function to determine if the error can be retried | ||
retryCondition = isNetworkOrIdempotentRequestError, | ||
retryDelay = noDelay | ||
retryDelay = noDelay, | ||
shouldResetTimeout = false | ||
} = getRequestOptions(config, defaultOptions); | ||
@@ -203,3 +206,3 @@ | ||
if (config.timeout && currentState.lastRequestTime) { | ||
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) { | ||
const lastRequestDuration = Date.now() - currentState.lastRequestTime; | ||
@@ -225,1 +228,2 @@ // Minimum 1ms timeout (passing 0 or less to XHR means no timeout) | ||
axiosRetry.exponentialDelay = exponentialDelay; | ||
axiosRetry.isRetryableError = isRetryableError; |
@@ -7,3 +7,3 @@ import * as axios from 'axios' | ||
* default: 3 | ||
* | ||
* | ||
* @type {number} | ||
@@ -13,5 +13,12 @@ */ | ||
/** | ||
* Defines if the timeout should be reset between retries | ||
* default: false | ||
* | ||
* @type {boolean} | ||
*/ | ||
shouldResetTimeout?: boolean, | ||
/** | ||
* A callback to further control if a request should be retried. By default, it retries if the result did not have a response. | ||
* default: error => !error.response | ||
* | ||
* | ||
* @type {Function} | ||
@@ -18,0 +25,0 @@ */ |
@@ -179,2 +179,4 @@ 'use strict'; | ||
* @param {number} [defaultOptions.retries=3] Number of retries | ||
* @param {boolean} [defaultOptions.shouldResetTimeout=false] | ||
* Defines if the timeout should be reset between retries | ||
* @param {Function} [defaultOptions.retryCondition=isNetworkOrIdempotentRequestError] | ||
@@ -206,3 +208,5 @@ * A function to determine if the error can be retried | ||
_getRequestOptions$re3 = _getRequestOptions.retryDelay, | ||
retryDelay = _getRequestOptions$re3 === undefined ? noDelay : _getRequestOptions$re3; | ||
retryDelay = _getRequestOptions$re3 === undefined ? noDelay : _getRequestOptions$re3, | ||
_getRequestOptions$sh = _getRequestOptions.shouldResetTimeout, | ||
shouldResetTimeout = _getRequestOptions$sh === undefined ? false : _getRequestOptions$sh; | ||
@@ -221,3 +225,3 @@ var currentState = getCurrentState(config); | ||
if (config.timeout && currentState.lastRequestTime) { | ||
if (!shouldResetTimeout && config.timeout && currentState.lastRequestTime) { | ||
var lastRequestDuration = Date.now() - currentState.lastRequestTime; | ||
@@ -245,2 +249,3 @@ // Minimum 1ms timeout (passing 0 or less to XHR means no timeout) | ||
axiosRetry.exponentialDelay = exponentialDelay; | ||
axiosRetry.isRetryableError = isRetryableError; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "axios-retry", | ||
"version": "3.0.2", | ||
"version": "3.1.0", | ||
"author": "Rubén Norte <ruben.norte@softonic.com>", | ||
@@ -5,0 +5,0 @@ "description": "Axios plugin that intercepts failed requests and retries them whenever posible.", |
# axios-retry | ||
Axios plugin that intercepts failed requests and retries them whenever posible. | ||
Axios plugin that intercepts failed requests and retries them whenever possible. | ||
@@ -56,3 +56,3 @@ ## Installation | ||
**Note:** the plugin interprets the request timeout as a global value, so it is not used for each retry but for the whole request lifecycle. | ||
**Note:** Unless `shouldResetTimeout` is set, the plugin interprets the request timeout as a global value, so it is not used for each retry but for the whole request lifecycle. | ||
@@ -63,5 +63,6 @@ ## Options | ||
| --- | --- | --- | --- | | ||
| retries | `Number` | 3 | The number of times to retry before failing | | ||
| retries | `Number` | `3` | The number of times to retry before failing. | | ||
| retryCondition | `Function` | `isNetworkOrIdempotentRequestError` | A callback to further control if a request should be retried. By default, it retries if it is a network error or a 5xx error on an idempotent request (GET, HEAD, OPTIONS, PUT or DELETE). | | ||
| retryDelay | `Function` | `0` | A callback to further control the delay between retried requests. By default there is no delay between retries. Another option is exponentialDelay ([Exponential Backoff](https://developers.google.com/analytics/devguides/reporting/core/v3/errors#backoff)). The function is passed `retryCount` and `error`. | | ||
| shouldResetTimeout | `Boolean` | false | Defines if the timeout should be reset between retries | | ||
| retryDelay | `Function` | `function noDelay() { return 0; }` | A callback to further control the delay between retried requests. By default there is no delay between retries. Another option is exponentialDelay ([Exponential Backoff](https://developers.google.com/analytics/devguides/reporting/core/v3/errors#backoff)). The function is passed `retryCount` and `error`. | | ||
@@ -68,0 +69,0 @@ ## Testing |
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
33346
452
83