-
Notifications
You must be signed in to change notification settings - Fork 548
Open
Labels
TwiDi-InProgressIssue is being actively worked on by TwiDIIssue is being actively worked on by TwiDIpriority: mediumImportant but not urgent; Workaround availableImportant but not urgent; Workaround availabletype: bugbug in the librarybug in the library
Description
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?
twilio-node/src/base/RequestClient.ts
Lines 37 to 66 in 55db7c2
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; | |
}; | |
} |
AleF83 and adar-h-healthyCopilot
Metadata
Metadata
Assignees
Labels
TwiDi-InProgressIssue is being actively worked on by TwiDIIssue is being actively worked on by TwiDIpriority: mediumImportant but not urgent; Workaround availableImportant but not urgent; Workaround availabletype: bugbug in the librarybug in the library