retry-axios
retry-axios copied to clipboard
Stalls on third attempt
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?
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.