Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plugins that reuse configs (e.g. axios-retry) don't work.

See original GitHub issue

Describe the bug

In case of a retry (e.g. via axios-retry) the following error is thrown:

Reason: the same interceptor has already set proper agents to the request config in a previous failed request.

image The retryCount on the screenshot is 1 which means that the same requested has already failed once and this is the first retry.

To Reproduce

Steps to reproduce the behavior:

run the code below.

Expected behavior

No error.

Code that reproduces the bug

const axios = require("axios");

const { CookieJar } = require('tough-cookie');
const client = axios.create({jar: new CookieJar()});

const axiosCookieJarSupport = require('axios-cookiejar-support').wrapper;

const retry = require("axios-retry");

(async function () {
    await client("");


  • OS: macOS
  • Node.js version: 14.20.0
  • axios version: 1.1.2
  • tough-cookie version: 4.1.2
  • axios-cookiejar-support: 4.0.3

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

andrewkuczcommented, Oct 23, 2022

@grenik Hello, funny I ran into the same exact issue. I decided to try my hand at a PR to implement a fix for this to allow agents if they are instances of Http(s)CookieAgent. Check it out, let me know if the approach is okay #609

grenikcommented, Oct 11, 2022

Maybe you can simply check if an http(s) agent is a CookieAgent?

Also, FYI axios-retry removes http(s) agents if they are default ones, but I am not sure if other libs do the same (e.g. retry-axios):

Also, a question: what to do in case of a proxy with authentication? We have a helper function that creates a pre-configured http agent to handle proxy with auth, but we cannot use it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

axios-retry not working as expected. What is wrong with my ...
A http 404 status code means the request was handled successfully but was invalid.
Read more >
retries-property not working when using axios v0.19.0-beta.1
The is being caused by the new mergeConfig implementation they are using. The retry code relies on injecting a axios-retry key into the...
Read more >
Top 5 axios-retry Code Examples - Snyk
Learn more about how to use axios-retry, based on axios-retry code examples created from the most popular ways it is used in public...
Read more >
axios-retry - npm
Axios plugin that intercepts failed requests and retries them whenever posible.. Latest version: 3.3.1, last published: 6 months ago.
Read more >
Axios Async/Await with Retry - DEV Community ‍ ‍
Also, don't forget to install it using Terminal. $ npm install retry-axios. This is an example of working code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found