You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We wanted to use this project for to retry random ECONNRESET errors however we noticed that they didn't get retried at all. There were a couple issues (including another broken interceptor), but there was still a bug in this project.
// If there's no config, or retries are disabled, return.
if (!config || config.retry === 0) {
return false;
}
If you are only retrying noResponseRetries we always return false.
I changed the logic to this, but it still has another bug that I didn't want to fix (which is that we should have distinct retry counters for the noResponseRetries and retry.
/**
* Determine based on config if we should retry the request.
* @param err The AxiosError passed to the interceptor.
*/
export function shouldRetryRequest(err: AxiosError) {
const config = (err.config as RaxConfig).raxConfig
// If there's no config, or retries are disabled, return.
if (!config) {
return false
}
// Only retry with configured HttpMethods.
if (!err.config.method || config.httpMethodsToRetry!.indexOf(err.config.method.toUpperCase()) < 0) {
return false
}
let retryLimit = 0
if (err.response) {
// This error has a response
// If this wasn't in the list of status codes where we want
// to automatically retry, return.
if (err.response.status) {
let isInRange = false
for (const [min, max] of config.statusCodesToRetry!) {
const status = err.response.status
if (status >= min && status <= max) {
isInRange = true
break
}
}
if (!isInRange) {
return false
}
}
retryLimit = config.retry || 0
} else {
retryLimit = config.noResponseRetries || 0
}
// If we are out of retry attempts, return
return config.currentRetryAttempt < retryLimit
}
The text was updated successfully, but these errors were encountered:
Hello,
We wanted to use this project for to retry random ECONNRESET errors however we noticed that they didn't get retried at all. There were a couple issues (including another broken interceptor), but there was still a bug in this project.
If you are only retrying noResponseRetries we always return false.
I changed the logic to this, but it still has another bug that I didn't want to fix (which is that we should have distinct retry counters for the noResponseRetries and retry.
The text was updated successfully, but these errors were encountered: