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

All retries have timeout of 1ms set despite not being set anywhere that way #242

Open
canpoyrazoglu opened this issue Sep 4, 2023 · 3 comments

Comments

@canpoyrazoglu
Copy link

canpoyrazoglu commented Sep 4, 2023

We have the following configuration:

axiosRetry(axiosInstance, { retries: 3 });

However, it never tries to retry. I also tried adding a onRetry handler, putting a console log inside. It never gets hit either, confirming that it indeed never retries.

When I override retryCondition it does get triggered though if I try to call isNetworkOrIdempotentRequestError with the error in the callback, I get Cannot read property 'status' of undefined.

After a failed request, axios-retry is retrying all requests with 1ms timeout, causing all of them to fail repeatedly.

What am I doing wrong?

(React Native 0.71.6, axios 0.27.2, axios-retry 3.3.1)

@yutak23
Copy link
Contributor

yutak23 commented Sep 5, 2023

it never tries to retry.

Can you provide details of the error when it does not retry so that we can better clarify the issue?

@canpoyrazoglu
Copy link
Author

canpoyrazoglu commented Sep 5, 2023

After digging deeper I've realized that the error Cannot read property 'status' of undefined is actually throwing at a place that a colleague wrote long time ago. I've fixed it, however, the issue still continues with another error. First, here is my original request:

{
   "message":"timeout of 2000ms exceeded",
   "name":"AxiosError",
   "config":{
      "transitional":{
         "silentJSONParsing":true,
         "forcedJSONParsing":true,
         "clarifyTimeoutError":false
      },
      "transformRequest":[
         null
      ],
      "transformResponse":[
         null
      ],
      "timeout":1,
      "xsrfCookieName":"XSRF-TOKEN",
      "xsrfHeaderName":"X-XSRF-TOKEN",
      "maxContentLength":-1,
      "maxBodyLength":-1,
      "env":{
         "FormData":null
      },
      "headers":{
         "Accept":"application/json, text/plain, */*",
         "user-device-id":"[redacted]",
         "x-client-version":"1.0.17",
         "Authorization":"Bearer [redacted]",
         "x-locale":"es"
      },
      "baseURL":"https://[redacted]",
      "method":"get",
      "url":"[redacted]",
      "axios-retry":{
         "retryCount":1,
         "lastRequestTime":1693897894950
      }
   },
   "code":"ECONNABORTED",
   "status":null
}

Notice that it has a timeout of 2000ms (normally it's 12 seconds though I reduced it temporarily for testing this issue). After the requests fail, I get this:

timeout of 1ms exceeded

Why is it trying again with a 1ms timeout? After initial (failing) request, it will (obviously) always fail again as timeout is 1ms. I think exponential backoff would be more appropriate.

My observation is that after initial (real request, made by me, not axios-retry) the timeout is set correctly at what I've provided. However, all the subsequent requests (the retry requests made by axios-retry) have a timeout set to 1ms, failing in rapid succession.

I'm not setting timeout anywhere to 1ms. THe only reference to timeout (either in axios or axios-retry in total) is only where I create axios instance:

Axios.create({
  baseURL: Config.API_URL,
  timeout: 2000,
  headers: {
    [...]
  },
});

So even if the error in my original issue was misleading, the actual issue remains. (I've updated the original issue and title to reflect the actual problem)

@canpoyrazoglu canpoyrazoglu changed the title Retry never triggers, isNetworkOrIdempotentRequestError throws "Cannot read property 'status' of undefined" All retries have timeout of 1ms set despite not being set anywhere that way Sep 5, 2023
@mishagale
Copy link

I suspect this might be caused by not setting the shouldResetTimeout flag to true.

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