Comments (13)
I'm also looking for exponential backoff, but even a simple way to control the retry timeout would be useful.
My suggestion is to have two configuration methods:
Simple config
retry: {
attempts: 5,
delay: 1000
}
or a function, to allow exponential backoff.
returning -1
means don't retry
returning 1000 * attempt
means that on attempt 5, the retry delay is 5 seconds.
retry: (attempt) => {
if (attempt > 5) { return -1 }
return 1000 * attempt
}
from axios-retry.
Well, I've basically just implemented this in my fork: https://github.com/s3rious/axios-retry/blob/master/es/index.js#L116
Config now receives 3 arguments, I've added delay
, which can be a simple number or a function which receives an attempt count as an argument and returns number.
If someone can help with tests and README.md
I think I can make it a PR.
from axios-retry.
@moose56 is working on it in #28
from axios-retry.
We wrote this plugin just to retry network errors and we didn't expect to retry too many times, but that's a feature that could be added (together with #2).
Perhaps a retryInterval
(that could be a number or a function that receives the request config
) would be a good option to add. Would you consider creating a PR?
from axios-retry.
Unfortunately, I realized a bit later that the environment that I am running my code in does not support JS promises (old version of SeaMonkey), sorry. This means no more axios for us.
Once I fix this, sure, but right now upgrading things is a "nice to have" for us.
from axios-retry.
I'm back, working on this.
from axios-retry.
@s3rious Just replaced the es/index.js
with your one and then tried like this but there was no delay axiosRetry(axios, { retries: 3,delay : 11000 });
from axios-retry.
interested in exponential delay as well
from axios-retry.
@towfiqi That's strange, have you rebuilt the lib after making changes?
I've just started a simple project with my fork, here is a gist, and delay works ok.
from axios-retry.
[edit] Incorrect statement.
@s3rious Why don't you create a PR?
from axios-retry.
Is there any progress on that?
from axios-retry.
Sorry I must have missed that there is a PR open... Thanks!
from axios-retry.
This is great.
from axios-retry.
Related Issues (20)
- Inconsistent Behavior of `isNetworkOrIdempotentRequestError` Function HOT 1
- Requiring cjs is broken since the last version (4.0.0)
- TypeError: axiosRetry is not a function in v4.0.0 HOT 11
- Module parse failed: Unexpected token (24:20) HOT 1
- Retry not working on HTTP 502 HOT 3
- How to handle errors HOT 2
- Combining `axios-retry` with other interceptors HOT 1
- [Feature request]onMaxRetryTimesExceeded to allow user to emit a custom error after retries done
- Provide option to trigger retry from successful (200) response in Axios's response interceptors HOT 4
- Do we still need `fixConfig`?
- Attach a unique id with request
- Axios-retry swallows the error response HOT 3
- Exponential delay has unnecessary final sleep HOT 2
- Introduce "axiosRetry.linearDelay"
- FormData not work HOT 1
- Abort during retry causes uncaught exception HOT 3
- Duplicated URL params HOT 5
- Retry post request HOT 1
- It looks like the onMaxRetryTimesExceeded function is not triggered HOT 1
- lastRequestTime is incorrect in 4.x but correct in 3.x
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 axios-retry.