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

timeout prop get lost when retrying #221

Open
ballonura opened this issue Dec 28, 2022 · 2 comments
Open

timeout prop get lost when retrying #221

ballonura opened this issue Dec 28, 2022 · 2 comments

Comments

@ballonura
Copy link

ballonura commented Dec 28, 2022

My setup:

import axios, { AxiosRequestConfig } from "axios";
import https from "https";
import axiosRetry, { isNetworkOrIdempotentRequestError, IAxiosRetryConfig } from "axios-retry";

const run = async () => {
  try {
    const axiosRequestConfig: AxiosRequestConfig = {
      timeout: 66,
      withCredentials: false,
      httpsAgent: new https.Agent({ rejectUnauthorized: true }),
    };
    const axiosInstance = axios.create(axiosRequestConfig);

    const axiosRetryConfig: IAxiosRetryConfig = {
      retries: 5,
      retryDelay: (retryCount) => retryCount * 1000,
      retryCondition: (error) => {
        console.log(12345, "retry", error.message);

        return (
          isNetworkOrIdempotentRequestError(error) ||
          error.code === "ECONNABORTED"
        );
      },
    };

    axiosRetry(axiosInstance as any, axiosRetryConfig);

    const { data } = await axiosInstance.get(
      "https://jsonplaceholder.typicode.com/todos/1"
    );



    console.log(data);
  } catch (error) {
    console.log("error");
  }
};

and the cosole.log() says:

12345 retry timeout of 66ms exceeded
12345 retry timeout of 1ms exceeded
12345 retry timeout of 1ms exceeded
12345 retry timeout of 1ms exceeded
12345 retry timeout of 1ms exceeded

the 1st retry is with 66ms and the others with 1ms

@andycloke
Copy link

same issue here. it works as expected when shouldResetTimeout: true but not when it's false/undefined like in the scenario above.

@mindhells
Copy link
Member

maybe related with #220
have you tried las version?

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