justinbeckwith / retry-axios Goto Github PK
View Code? Open in Web Editor NEW🦖 A super flexible interceptor for Axios that makes it easy to retry requests.
License: Apache License 2.0
🦖 A super flexible interceptor for Axios that makes it easy to retry requests.
License: Apache License 2.0
The code to compute the linear backoff and exponential backoff has some issues, as it does not wait in the first attempt, this is because currentRetryAttempt
is initially set to 0 instead of 1. See
Lines 183 to 188 in c284310
It also does not consider the retryDelay
, which according to the readme:
Milliseconds to delay at first. Defaults to 100.
Additionally, the formula for computing the exponential backoff should be something like:
Math.min((Math.pow(2, config.currentRetryAttempt) + Math.random()), MAX_DELAY) * 1000
See https://cloud.google.com/iot/docs/how-tos/exponential-backoff#example_algorithm
That would give retry times like:
1.234
2.314
4.012
Compare that to the times obtained with the current algorithm:
0
0.5
1.5
I created the following gist to demonstrate the inability to override the config beyond the defaults. Executing this script fails on first attempt and no retry is executed. Using default settings, as shown in method 1, I've seen the 3 retry attempts in the config but this gist does not have that working. Execution methods are in comments at the bottom of the file.
https://gist.github.com/mkiddTempus/4ce156382c1b654b34d44d1900a37d2b
Using a custom HttpsAgent to make requests over proxy. Whenever a request fails, rax tries to retry the request but following error occurs.
The "options.agent" property must be one of type Agent-like Object, undefined, or false. Received type object
TypeError [ERR_INVALID_ARG_TYPE]: The "options.agent" property must be one of type Agent-like Object, undefined, or false. Received type object
at new ClientRequest (_http_client.js:112:11)
at Object.request (https.js:303:10)
at dispatchHttpRequest (/xxx/node_modules/axios/lib/adapters/http.js:141:25)
at new Promise ()
at httpAdapter (/xxx/node_modules/axios/lib/adapters/http.js:18:10)
at dispatchRequest (/xxx/node_modules/axios/lib/core/dispatchRequest.js:59:10)
Before the "retry" trials, custom agent and all the requests works.
Independently both "shouldRetry"and "retry" work fine.
When put together, "retry" loses it significance.
`
raxConfig: {
retry: 5,
shouldRetry: (err) => {
if(condition) return true;
else return false;
},
onRetryAttempt: (err) => {
return true;
},
},
`
For the above raxConfig, it doesn't stop after 5 retries. It retries infinitely.
Using /v1/api via:
window.axios.defaults.baseURL = '/v1/api/'
On error results in
'/v1/api/v1/api' call
Hi @JustinBeckwith I wanted to check if this project is still maintained and whether you would be willing to accept contributions.
I see that there are a couple of duplicated issues, dating a long back, and also there are some new issues reported.
So, following the example for an async onRetryError, I decide to not retry is errno === "ENOTFOUND"
(kinda no point, right?)
So, I call my reject
function. But I always get an UnhandledPromisRejectionWarning
on those.
So it looks like there is no catch block for those?
By default , retry count is set to 3. But It's only trying two times. Doesn't have any effect if I define it to be 3, 4 or 5. It only tries 2 times. Please fix this issue. Thanks
I need to show an error icon in between the request retries. Is there any way to do this?
I want to use this library in client-side (browser) JS but from a hosted platform where I can't store my own files. I'm loading axios from Cloudflare CDN using LazyLoad and it works fine, but I tried also loading retry-axios that way and got an immediate error as it was referring to axios by pathname. Is it possible to do what I'm trying to do?
Hello,
How could I create rax with options to add it to the global interceptor?
Thank you
The line below in the function onError
sometimes throws error "Cannot set property 'raxConfig' of undefined"
It happened when an axios call encountered a 401 error.
// Put the config back into the err
err.config.raxConfig = config;
Looks like the err.config
could be undefined
.
Does NOT work
import axios from 'axios';
import rax from 'retry-axios';
console.log('TEST', rax); // TEST undefined
WORKS
import axios from 'axios';
const rax = require('retry-axios');
console.log('TEST', rax); // TEST { attach: [Function: attach], detach: [Function: detach], getConfig: [Function: getConfig] }
Is something up with the way this was packaged that would prevent it from being imported when working with webpack+babel?
I want to use this package but it contains non-es5 keywords (const
) in the output file.
Hi,
I am using this library to retry 500 requests, but it is not being retried because when the request is wrapped in a try catch block, the 500 response is returned in the catch.
How are you handling this?
I'm using retry-axios succesfully to retry on server-side errors like 5xx responses.
However, I'm also experiencing sporadically timeouts on the server-side. In this cases, there is no retry attempt.
I would consider timeouts a service-side error as well. Shouldn't there be a retry attempt?
This is likely just my own mis-understanding of Node.js, but based on the docs I would assume this should work:
const rax = require('retry-axios');
const {axios} = require('axios');
async function main() {
const interceptorId = rax.attach();
const res = await axios('https://localhost');
}
main()
But instead it reports:
(node:50585) UnhandledPromiseRejectionWarning: TypeError: axios is not a function
I also tried:
const rax = require('retry-axios');
const Axios = require('axios')
const axios = Axios.create()
axios.defaults = {
raxConfig: {
onRetryAttempt: (err) => {
const rcfg = rax.getConfig(err)
console.log(`Retry attempt #${cfg.currentRetryAttempt}`)
}
}
}
const interceptorId = rax.attach(axios)
async function main() {
res = await axios.get('https://localhost')
}
main()
I am hoping to have it catch connection refused (no server responding) and wait to retry... but it just errors out. My guess is I'm still missing somewhat on getting the syntax lined up.
This is on node.js v10.4.1, with no babel.
Thanks!
Hello
Im trying to use this library but i get the following error in my catch block
Cannot read property 'attach' of undefined
import axios from "axios";
import rax from "retry-axios";
try {
const interceptorId = rax.attach();
const metrics = await axios(this.getMetrics(session._id, sessionRequest._id));
} catch(err) {
console.log(err);
}
public getMetrics(sessionId: any, requestId: any) {
const url = this.config.backendUrl + "/check/metrics";
const options = {
url,
method: "get",
headers: {
"X-IDCHECK-SESSION-ID": sessionId,
},
data: {},
raxConfig: {
// 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.
retryDelay: 100,
// HTTP methods to automatically retry. Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ["GET", "HEAD", "OPTIONS", "DELETE", "PUT"],
// The response status codes to retry. Supports a double
// array with a list of ranges. Defaults to:
// [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry: [[100, 199], [429, 429], [500, 599]],
// If you are using a non static instance of Axios you need
// to pass that instance here (const ax = axios.create())
// instance: ax,
// You can detect when a retry is happening, and figure out how many
// retry attempts have been made
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
},
},
};
return options;
}
My English is not good, sorry, please be patient and finish reading! It seems that retry-axios can only retry one request, but there are multiple real-time requests on the webpage, which cannot meet the needs of the project! Is there a setting or other scheme that can handle multiple requests and retry?
The raxConfig
requires an instance
field, which if not set will default to the default axios instance, however that's not what one wants when attaching it to a non-default instance.
This is awkward an error prone, as one would need to create the object as follows:
const axiosInstance = axios.create({
raxConfig: {
retryDelay: 10000,
backoffType: 'static',
},
});
axiosInstance.defaults.raxConfig = {...axiosInstance.defaults.raxConfig, instance: axiosInstance};
Instead, I suggest to modify attach to do something like:
export function attach(instance?: AxiosInstance) {
if (instance) {
instance.defaults.raxConfig = {...instance.defaults.raxConfig, instance};
}
instance = instance || axios;
return instance.interceptors.response.use(onFulfilled, onError);
}
this.$emataRequest.defaults.raxConfig = {
retry: 5,
retryDelay: 10000,
statusCodesToRetry: [
[100, 199],
[400, 429],
[500, 599]
],
}
All other settings are perfoming as expected except retryDelay
When specify statusCodesToRetry as 2xx, this doesn't work because of the following code:
export function attach(instance?: AxiosInstance) {
instance = instance || axios;
return instance.interceptors.response.use(onFulfilled, onError);
}
onError will be only triggered when the Http Status Code is not 2xx. That means all retries this library will perform only works when Http Status Code is not 2xx.
EDIT: I swapped retry-axios for axios-retry @ https://github.com/softonic/axios-retry , using the same logical flow and it works fine with proper repeats. What's so different about retry-axios' implementation?
Hello.
I've been trying to get this wonderful interceptor all day but I just can't get it to work with my React app.
I have the following code.
export default{
get(url, conf = {}) {
const client = getClient();
client.defaults.raxConfig = {
retry: 5,
instance: client,
noResponseRetries: 5,
statusCodesToRetry: [[100, 199], [400, 429],[500, 599]],
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
}
}
const interceptorId = rax.attach(client)
return client.get(url, conf)
}
}
Basically another apiCall.js file calls the exported function, it creates an axios instance with some basic options via getClient(), attaches the raxConfig, attaches rax itself and then returns the get request.
The apiCall.js file then resolves the promises via .then() and .catch().
The problem im experiencing is no matter what I do retry-axios only retries once.
I know it uses the config because it properly reacts to changes in statusCodesToRetry, but doesn't do anything after the first retry.
I'm really desperate here and any help is appreciated. Thank you.
Hi all, I'm rather new to using axios and needed a way to perform some retries when requests failed. I was going through the README docs and got up and running real quick, but then I hit a brick wall, and found retry-axios not working what so ever. After figuring out my mistake I wanted to point out where I "went wrong", either to help others who ran into similar issues, or to possibly improve the docs to prevent my mistakes from happening to others.
Currently the README has this snippet:
const myAxiosInstance = axios.create();
myAxiosInstance.defaults = {
raxConfig: {
instance: myAxiosInstance
}
}
const interceptorId = rax.attach(myAxiosInstance);
const res = await myAxiosInstance.get('https://test.local');
Which I used for my own setup, and found rax wasn't working, where the onRetryAttempt
method wasn't being called. After struggling with all the retry-config settings I eventually changed my code to look this like:
const myRaxConfig = {/*my settings*/};
const myAxiosInstance = axios.create();
myAxiosInstance.defaults.raxConfig = myRaxConfig;
const interceptorId = rax.attach(myAxiosInstance);
const res = await myAxiosInstance.get('https://test.local');
After-which retry-axios started working, and started calling the onRetryAttempt
callback.
It seems when doing this:
myAxiosInstance.defaults = {
raxConfig: {
/*my rax config settings*/
}
}
You take the following (rough) default axios configs:
{
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"headers": {
"common": {
"Accept": "application/json, text/plain, */*"
},
"delete": {},
"get": {},
"head": {},
"post": {
"Content-Type": "application/x-www-form-urlencoded"
},
"put": {
"Content-Type": "application/x-www-form-urlencoded"
},
"patch": {
"Content-Type": "application/x-www-form-urlencoded"
}
}
and set it to just the rax config. (as seen in the code-snippet at the top)
So I think we should update this snippet in the README to prevent any issues where developers use the code snippet without realizing they are effectively removing a bunch of default settings for axios.
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.
First, really neat interceptor with a great API.
IS:
IE11 throws:
SCRIPT1002: Syntax error
All arrow functions aren't transpiled, see:
https://unpkg.com/[email protected]/build/src/index.js
EXPECTED:
I expect to import an ES Module and bundle it with Webpack/Rollup/Parcel without the need to transpile retry-axios
itself by Babel.
I'm talking about the provided main
and missing module
field as definied by the spec below:
Line 5 in fc8117e
pkg.module
will point to a module that has ES2015 module syntax but otherwise only syntax features that the target environments support.
https://github.com/rollup/rollup/wiki/pkg.module
Wait, it just means import and export – not other future JavaScript features?
Yes. ...
https://github.com/rollup/rollup/wiki/pkg.module#wait-it-just-means-import-and-export--not-other-future-javascript-features
Babel allows you to disable just module syntax transpilation:
https://babeljs.io/docs/en/babel-preset-env#modules
And Rollup, Webpack etc can be configured to target a specific module syntax.
it's not working with axios v.19.0
Something like this would help to avoid errors when trying to add options to axios instances options.
declare module 'axios' {
export interface AxiosRequestConfig {
raxConfig?: RetryConfig
}
}
Today if we install the library using the example given in the readme it fails to compile ts.
import rax, { RetryConfig } from 'retry-axios';
import axios from 'axios';
export const myAxiosInstance = axios.create();
myAxiosInstance.defaults.raxConfig = { // <-- unkown property
instance: myAxiosInstance
};
export const axiosRetryInterceptorId = rax.attach(myAxiosInstance);
This library looks like exactly what I need. I am trying it out with code like this:
rax.attach();
axios.defaults.raxConfig = {
onRetryAttempt: err => {
const cfg = rax.getConfig(err);
console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
}
};
axios.interceptors.response.use(interceptors.response.success, interceptors.response.error);`
interceptors.response.error
is where I build up custom error for logging, which includes the request & response details. At the top I threw this in:
console.log(e.message);
console.log(typeof e.config);
When I purposefully error via gibberish URL the console.logs output this:
Retry attempt #1
Retry attempt #2
getaddrinfo ENOTFOUND www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com:80
object
getaddrinfo ENOTFOUND www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com www.asdlkfjaslfkjadflkjfadslfjnafdslkfasd.com:80
undefined
How should I ensure that my logic only runs after final attempt AND for any error that has no retries? ie an error with POST, which would never really run onRetryAttempt
Right now it looks to fire your plugin twice followed by my generic handler twice.
hi, I am trying to use retry even if status code of 200, I want to check response body and if it pass custom if then resolve if not to retry again, any examples how to do this?
const rax = require('retry-axios'); const axios = require('axios');
const response = await axios({
method: 'post',
url: url,
headers: {
'Accept': 'application/json;charset=utf-8',
'Content-Type': 'application/json;charset=utf-8'
},
responseType: 'json',
httpsAgent: new https.Agent({
rejectUnauthorized: false
}),
data: body,
auth: {
username: user,
password: password,
},
}, );
ERROR :
stack:"TypeError: Cannot read property 'raxConfig' of undefined\n
odeceptjs\node_modules\retry-axios\build\src\index.js:29:31)\n at process._tickCallback (internal/process/next_tick.js:68:7)"
I get this error: "Error: socket hang up" and the is not retiring as there is no HTTP response.
raxConfig: {
retry: 3,
noResponseRetries: 5,
instance: http,
retryDelay: 100,
httpMethodsToRetry: ['GET', 'OPTIONS', 'POST'],
shouldResetTimeout: false,
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(cfg.currentRetryAttempt);
}
}
When using two axios requests, the retry method works in the 1st request but doesn't work in 2nd request which is made after the 1st request. When calling the 2nd request an error is thrown and retry is not triggered.
Output: UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
Exmaple:
` rax.attach();
const res = await axios({
url: 'https://postman-echo.com',
method: 'post',
raxConfig: {
// Retry 3 times on requests that return a response (500, etc) before giving up. Defaults to 3.
retry: 2,
// Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
noResponseRetries: 2,
// HTTP methods to automatically retry. Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ['GET', 'POST', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],
// The response status codes to retry. Supports a double
// array with a list of ranges. Defaults to:
// [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry: [[100, 199], [400, 499], [500, 599]],
// Milliseconds to delay at first. Defaults to 100.
retryDelay: 100,
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(Retry attempt #${cfg.currentRetryAttempt}
);
} } }); `
`
rax.attach();
const res = await axios({
url: 'https://postman-echo.com',
method: 'post',
raxConfig: {
// Retry 3 times on requests that return a response (500, etc) before giving up. Defaults to 3.
retry: 2,
// Retry twice on errors that don't return a response (ENOTFOUND, ETIMEDOUT, etc).
noResponseRetries: 2,
// HTTP methods to automatically retry. Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ['GET', 'POST', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],
// The response status codes to retry. Supports a double
// array with a list of ranges. Defaults to:
// [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry: [[100, 199], [400, 499], [500, 599]],
// Milliseconds to delay at first. Defaults to 100.
retryDelay: 100,
onRetryAttempt: (err) => {
const cfg = rax.getConfig(err);
console.log(Retry attempt #${cfg.currentRetryAttempt}
);
} } });`
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
The npm token configured in the NPM_TOKEN
environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/
.
If you are using Two-Factor Authentication, make configure the auth-only
level is supported. semantic-release cannot publish with the default auth-and-writes
level.
Please make sure to set the NPM_TOKEN
environment variable in your CI with the exact value of the npm token.
Good luck with your project ✨
Your semantic-release bot 📦🚀
is there any change to add support for the Retry-After
header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After).
This is specially useful to deal with quota exceeded errors (429).
Probably an upper bound should be added, so that one doesn't wait forever. In that way is the service is going to be down for a while (503) or if you have no quota left, then the request would fail immediately without even retrying.
Hey i am recieving this error im not sure why.
TypeError: Cannot read property 'raxConfig' of undefined
const requestOptions = {
url,
method: "get",
headers: {
"X-IDCHECK-SESSION-ID": sessionId,
},
};
requestOptions.raxConfig = {
// Override the decision making process on if you should retry
// 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.
retryDelay: 100,
// HTTP methods to automatically retry. Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ["GET", "HEAD", "OPTIONS", "DELETE", "PUT"],
// The response status codes to retry. Supports a double
// array with a list of ranges. Defaults to:
// [[100, 199], [429, 429], [500, 599]]
statusCodesToRetry: [
[100, 199],
[429, 429],
[500, 599]
],
// If you are using a non static instance of Axios you need
// to pass that instance here (const ax = axios.create())
// instance: ax,
// You can detect when a retry is happening, and figure out how many
// retry attempts have been made
onRetryAttempt: (err) => {
const cfg = getConfig(err);
console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
},
};
try {
result = await axios(requestOptions);
} catch(err) {
console.log(err)
}
url: '0.0.0.0:9999',
method: 'get',
headers: { 'X-IDCHECK-SESSION-ID': 5cd40e29268b04fc002c4575 },
raxConfig: {
retry: 3,
noResponseRetries: 2,
retryDelay: 100,
httpMethodsToRetry: [ 'GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT' ],
statusCodesToRetry: [ [Array], [Array], [Array] ],
onRetryAttempt: [Function: onRetryAttempt]
}
}
TypeError: Cannot read property 'raxConfig' of undefined
at onError (/node_modules/retry-axios/src/index.ts:90:44)
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
The npm token configured in the NPM_TOKEN
environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/
.
If you are using Two-Factor Authentication, make configure the auth-only
level is supported. semantic-release cannot publish with the default auth-and-writes
level.
Please make sure to set the NPM_TOKEN
environment variable in your CI with the exact value of the npm token.
Good luck with your project ✨
Your semantic-release bot 📦🚀
Same currentRetryAttempt value is shared by all the request made by an axios instance. This leads to unreliable retry attempts when working with mass parallel requests.
Hi,
I get the following error
Property 'raxConfig' does not exist on type 'AxiosRequestConfig'.ts(2339)
const myAxiosInstance = axios.create();
myAxiosInstance.defaults.raxConfig = {
instance: myAxiosInstance,
};
const interceptorId = attach(myAxiosInstance);
I have a use-case where I only want to retry if it's ENOTFOUND
, ETIMEDOUT
, etc.
However, if I config:
retry: 0,
noResponseRetries: 3,
it doesn't attempt to retry on these errors at all.
Is there an easy way to configure it to retry these errors ONLY?
Error cannot read property 'raxConfig' of undefined
is occurring when a method called inside the axios interceptor throws a custom error.
Example:
Interceptor:
axios.interceptors.request.use (
async request => {
request.headers.Authorization = await auth.getToken();
return request
},
error => { ... }
);
Method (auth.getToken()
):
async getToken() {
if (!this.auth.getCachedSession().isValid()) {
throw new Error('Session has expired.');
} else {
return this.getAccessToken();
}
}
This error is happenning because custom error does not have a config
object. Then the onError
method of the retry-axios
try to access error.config,raxConfig
A possible fix would be modifying onError
function as following.
function onError(err) {
if (!err.config) {
return Promise.reject(err);
}
...
}
How can I use retry-axios in a React Component. If i follow the guideline by
import axios from 'axios'; import { rax } from 'retry-axios'; const interceptorId = rax.attach();
I get an error
Cannot read property 'attach' of undefined
at the line where I define const interceptorId = rax.attach();
Did anyone get it working in React?
In function shouldRetryRequest
there's this block of code
// Only retry with configured HttpMethods.
if (!err.config.method ||
config.httpMethodsToRetry.indexOf(err.config.method.toUpperCase()) < 0) {
return false;
}
that fails evaluating second condition, because httpMethodsToRetry
is an object, not an array.
Below goes the output from dev console, when the breakpoint was set on the line given above ^^^:
config.httpMethodsToRetry
{0: "GET", 1: "HEAD", 2: "OPTIONS", 3: "DELETE", 4: "PUT"}
That looks different from what gets set in raxConfig
const raxConfig = {
....
// HTTP methods to automatically retry. Defaults to:
// ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']
httpMethodsToRetry: ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT'],
}
When chain this interceptor with another global interceptor that displays an error message, it would be helpful to easily know if this request is the final retry of rax.
Currently, the logic to determine if the current retry is the final one is kind of complicated because of retries
and noResponseRetries
We did not find any information about how the timeout acts when retry behaviour comes up.
given
axios.post(path, body, {
baseURL: ur;,
timeout: 12000,
raxConfig: {
retry: 5,
retryDelay: 500,
},
is the timeout of 12sec apply for all the 5 retries ? so 12 sec for performing 5 possible requests ?
or for each retry, the timeout is reset to 12sec ? being possibly 12sec * 5 attempts ?
can you please introduce this documentation in the main README ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.