Git Product home page Git Product logo

Comments (13)

antony avatar antony commented on September 3, 2024 6

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.

s3rious avatar s3rious commented on September 3, 2024 1

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.

rubennorte avatar rubennorte commented on September 3, 2024 1

@moose56 is working on it in #28

from axios-retry.

rubennorte avatar rubennorte commented on September 3, 2024

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.

chuckhacker avatar chuckhacker commented on September 3, 2024

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.

TheChuckster avatar TheChuckster commented on September 3, 2024

I'm back, working on this.

from axios-retry.

towfiqi avatar towfiqi commented on September 3, 2024

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

yipcma avatar yipcma commented on September 3, 2024

interested in exponential delay as well

from axios-retry.

s3rious avatar s3rious commented on September 3, 2024

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

gregorym avatar gregorym commented on September 3, 2024

[edit] Incorrect statement.

@s3rious Why don't you create a PR?

from axios-retry.

matthiasfeist avatar matthiasfeist commented on September 3, 2024

Is there any progress on that?

from axios-retry.

matthiasfeist avatar matthiasfeist commented on September 3, 2024

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

from axios-retry.

dashmug avatar dashmug commented on September 3, 2024

This is great.

from axios-retry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.