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

retries for network errors (e.g. ECONNRESET) #1023

Open
mfulton26 opened this issue Jun 6, 2024 · 3 comments
Open

retries for network errors (e.g. ECONNRESET) #1023

mfulton26 opened this issue Jun 6, 2024 · 3 comments

Comments

@mfulton26
Copy link

mfulton26 commented Jun 6, 2024

sometimes Twilio calls fail for intermittent network/server errors (e.g. ECONNRESET); can the Auto-Retry with Exponential Backoff be updated or a similar option added to also retry under these conditions?

function getExponentialBackoffResponseHandler(
axios: AxiosInstance,
opts: ExponentialBackoffResponseHandlerOptions
) {
const maxIntervalMillis = opts.maxIntervalMillis;
const maxRetries = opts.maxRetries;
return function (res: AxiosResponse<any, any>) {
const config: BackoffAxiosRequestConfig = res.config;
if (res.status !== 429) {
return res;
}
const retryCount = (config.retryCount || 0) + 1;
if (retryCount <= maxRetries) {
config.retryCount = retryCount;
const baseDelay = Math.min(
maxIntervalMillis,
DEFAULT_INITIAL_RETRY_INTERVAL_MILLIS * Math.pow(2, retryCount)
);
const delay = Math.floor(baseDelay * Math.random()); // Full jitter backoff
return new Promise((resolve: (value: Promise<AxiosResponse>) => void) => {
setTimeout(() => resolve(axios(config)), delay);
});
}
return res;
};
}

@adar-h-healthy
Copy link

@tiwarishubham635 Can you please relate to this one? 🙏 We started to get multiple ECONNABORTED errors and this addition can help a lot.

@tiwarishubham635
Copy link
Contributor

We have recently made these changes. I think this will help in your case. This will be available in the coming release

@adar-h-healthy
Copy link

@tiwarishubham635 I might be missing something, but I can't see how this change can help here... It gives the option to change the timeout value, but it doesn't allow to override the retry configuration.

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