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

Axios request automatically fired a second time after a delay #6287

Open
AbdelkaderMkd opened this issue Mar 10, 2024 · 3 comments
Open

Axios request automatically fired a second time after a delay #6287

AbdelkaderMkd opened this issue Mar 10, 2024 · 3 comments

Comments

@AbdelkaderMkd
Copy link

Describe the bug

In my NodeJS backend, I have an Axios API call to a microservice that involves extensive operations and takes approximately 4 minutes to complete. The issue I'm facing is that, despite the initial call not encountering any problems or finishing its execution, a duplicate request is automatically triggered after approximately 2 minutes.

To Reproduce

  1. The server get a call to the specific route
  2. The controller triggered an Axios GET request to a microservice

Code snippet

@Get("/SchemaExp/:rd")
  @Authorized(["admin"])
  async SchemaExp(@Req() req: Request, @Res() res: Response, @Param("rd") rd: string): Promise<any> {
    console.log("SchemaExp route: ", new Date());
    return new Promise<any>(async (resolve, reject) => {
      axios
        .get(`http://${MICROSERVICE_HOST}:${MICROSERVICE_PORT}/SE/` + rd, {
          headers: {
            token: req.cookies.token,
          },
        })
        .then(function (response) {
          resolve(response);
        })
        .catch(function (error) {
          reject(error);
        })
        .finally(function () {
          console.log("finally");
        });
    });
  }

Expected behavior

I expect Axios to send only one request.

Axios Version

1.6.7

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

20.10.0

OS

Windows 10

Additional Library Versions

axios 1.4.0
express 4.18.3

Additional context/Screenshots

To identify whether the bug lies within Axios, I attempted to invoke the microservice endpoint using Postman and I didn't encounter the issue. Additionally, as a temporary measure while awaiting a solution, I replaced Axios with another fetch library (Superagent), and it functioned without any problems.
@NgoDuy2197
Copy link

Hello i'm facing the same issue.

In my case. I use axios in service A call api service B. When i debug, i see it jump to api service B 4 times. Service A only call api 1 times.

Have u resolved this issue ?

@AbdelkaderMkd
Copy link
Author

Unfortunately, I haven't made any progress.

@misakamayako
Copy link

chrome will auto retry after 120s if it's too slow, and this new one will not shown in dev tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants