Comments (7)
downgrading worked for me. thanks @khitrenovich !
but the retries count here stays at 1 regardless of how many retries I gave it
from retry-axios.
Possible duplicate of #68
I spent some time diving into the problem (as I saw the same happening in one of my projects) and figured out that response interceptor installed by retry-axios
is not being called on the second attempt, causing the failure to propagate immediately instead of retrying. This is likely a regression introduced in v0.19.x of axios
, as mentioned in https://github.com/chinesedfan/You-Dont-Know-Axios#config-defaults:
0.19, introduces a new util method called
deepMerge
, which will clone the object when replacing, but with some bugs. Arrays are cloned as objects. Some config fields (i.e.params
) should be supported deep merging but not, and custom default fields are lost totally.
Downgrading axios
to v0.18.1 solved the issue for me.
from retry-axios.
Seeing this too. The setting has no effect and only 2 attempts are tried.
Edit: I tried all versions, including the 0.20 beta, and 0.18 downgrade
from retry-axios.
@moltar How did you set up the raxConfig? I'm asking because I identified issue #124, in which if you use a custom axios instance, then it won't work unless you also specify the instance
field.
from retry-axios.
I was having a similar problem using the following setup:
const instance = Axios.create();
instance.defaults.raxConfig = { ... };
instance.get(...)
Changing the values in raxConfig above was having no effect. When I saw this ticket, I noticed I was using axios 0.19 and updated it to axios 0.21, which solved the problem for me
from retry-axios.
So this is a little confusing :) One thing to look out for here, are that there are separate settings for retry
and noResponseRetries
. The retry
number will be used if you connect to the endpoint, and get a non-2xx response. The noResponseRetries
is specifically used in the case where the connection was never made, like ETIMEDOUT
or ENOTFOUND
errors.
To get it to use 3 retries every time (regardless of the reason it fails), this ought to work:
const rax = require('retry-axios');
const axios = require('axios');
rax.attach();
async function main() {
try {
await axios({
url: 'https://test.local',
raxConfig: {
retry: 3,
noResponseRetries: 3,
onRetryAttempt: err => {
const cfg = rax.getConfig(err);
console.log(`Retry attempt #${cfg.currentRetryAttempt}`);
}
},
});
} catch (err) {
console.error(err);
}
}
main();
Note, this is using:
- Node.js 14.17..3
- axios 0.21.1
- retry-axios 2.5.0
For anyone else that comes here - please make sure to post the exact code you're using :) Also, it would be helpful to include the versions of axios and retry-axios, as well as the error you're getting when the request fails.
from retry-axios.
It works with the default axios, but doesn't work with axios instance (axios.create()
). See #68 (comment)
from retry-axios.
Related Issues (20)
- Exponential Retry should be configurable. By default is 1000ms HOT 2
- Add "PATCH" operations to the httpMethodsToRetry HOT 2
- Question re: max retry delay HOT 3
- Dependency Dashboard
- A jitter option would be a nice feature HOT 1
- Stalls on third attempt HOT 1
- Retry on non-error codes HOT 1
- Question: Network shutdown case
- Problem with 3.0.0 HOT 6
- This lib does not work no node_threads HOT 12
- BUG: noResponseRetries > 0 not retried
- v3 Breaks Typescript Build HOT 6
- v3 no longer supports browser usage?
- onRetryAttempt how to change baseUrl dinamically while retrying HOT 2
- Question: Exponential Backoff execution times HOT 1
- Import fails after Jest v28 update (Cannot use import statement outside a module) HOT 5
- Failed to execute 'setRequestHeader' on 'XMLHttpRequest'
- retry-axios doesn't work with latest axios release v1.1.3 HOT 4
- Also supports CommonJS HOT 1
- Cannot find module 'retry-axios' or its corresponding type declarations HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from retry-axios.