retry-axios icon indicating copy to clipboard operation
retry-axios copied to clipboard

Stalls on third attempt

Open elie222 opened this issue 4 years ago • 1 comments

This is our config:

const axiosInstance = axios.create({
  headers: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
  },
})
axiosInstance.defaults.raxConfig = {
  retry: 3,
  instance: axiosInstance,
  onRetryAttempt: evt => {
    console.log(`onRetryAttempt. attempt #${evt.config!.raxConfig?.currentRetryAttempt}`)
  },
}
const interceptorId = rax.attach(axiosInstance)

After printing onRetryAttempt. attempt #2 it just stops altogether. I would have thought it would error and we could continue on from there but it just halts everything.

Are we doing something wrong?

elie222 avatar Oct 26 '21 20:10 elie222

I am seeing the same thing. I am using my own custom shouldRetry handler to get around this. If you add

shouldRetry: (error) => {
  const cfg = rax.getConfig(error);
  console.log(cfg);

  return return rax.shouldRetryRequest(error);
}

you will see that on the second run the httpMethodsToRetry and statusCodesToRetry properties are empty arrays. I'm assuming that internally they are relying on this same code, so an empty array for both of those means that it is just ignoring everything and only retrying a single time instead of the 3 times you configured it to run for.

daneren2005 avatar Jan 20 '22 20:01 daneren2005