Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exponential backoff? #3

Closed
chuckhacker opened this issue Jan 23, 2017 · 13 comments
Closed

Exponential backoff? #3

chuckhacker opened this issue Jan 23, 2017 · 13 comments

Comments

@chuckhacker
Copy link

It's "good practices" to have exponential backoff for successive retries. Any plans to implement this?

@rubennorte
Copy link
Contributor

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?

@chuckhacker
Copy link
Author

chuckhacker commented Feb 2, 2017

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.

@antony
Copy link

antony commented Mar 9, 2017

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
}

@TheChuckster
Copy link

I'm back, working on this.

@s3rious
Copy link

s3rious commented Aug 3, 2017

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.

@towfiqi
Copy link

towfiqi commented Sep 6, 2017

@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 });

@yipcma
Copy link

yipcma commented Sep 10, 2017

interested in exponential delay as well

@s3rious
Copy link

s3rious commented Sep 14, 2017

@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.

@gregorym
Copy link

gregorym commented Nov 7, 2017

[edit] Incorrect statement.

@s3rious Why don't you create a PR?

@matthiasfeist
Copy link

Is there any progress on that?

@rubennorte
Copy link
Contributor

@moose56 is working on it in #28

@matthiasfeist
Copy link

Sorry I must have missed that there is a PR open... Thanks!

@dashmug
Copy link

dashmug commented Jan 17, 2018

This is great.

lbebber added a commit to lbebber/axios-retry that referenced this issue Sep 20, 2018
Change eslint config to eslint-config-vtex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants