Code Monkey home page Code Monkey logo

Comments (7)

quang-m-nguyen avatar quang-m-nguyen commented on June 13, 2024 2

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.

khitrenovich avatar khitrenovich commented on June 13, 2024 1

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.

moltar avatar moltar commented on June 13, 2024

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.

sk- avatar sk- commented on June 13, 2024

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

reisandbeans avatar reisandbeans commented on June 13, 2024

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.

JustinBeckwith avatar JustinBeckwith commented on June 13, 2024

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.

orgads avatar orgads commented on June 13, 2024

It works with the default axios, but doesn't work with axios instance (axios.create()). See #68 (comment)

from retry-axios.

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.