From b82736c93861172e3f3621856a23cb7ea9d994b3 Mon Sep 17 00:00:00 2001 From: f1cognite Date: Fri, 9 Aug 2019 16:22:33 +0200 Subject: [PATCH] fix: retry ETIMEDOUT connection failures --- src/retryRequests.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/retryRequests.ts b/src/retryRequests.ts index 9534a72684..8c6777601d 100644 --- a/src/retryRequests.ts +++ b/src/retryRequests.ts @@ -48,6 +48,7 @@ const httpMethodsToRetry = ['GET', 'HEAD', 'OPTIONS', 'DELETE', 'PUT']; const statusCodesToRetry = [[100, 199], [429, 429], [500, 599]]; /** @hidden */ +// tslint:disable-next-line:cognitive-complexity export function addRetryToAxiosInstance(instance: AxiosInstance) { // config for retry-axios package (instance.defaults as RaxConfig).raxConfig = { @@ -66,6 +67,18 @@ export function addRetryToAxiosInstance(instance: AxiosInstance) { return false; } + // Handle ETIMEDOUT's + // An unexpected error occurred { Error: connect ETIMEDOUT 34.76.254.249:443 + // at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1083:14) + // errno: 'ETIMEDOUT', + // code: 'ETIMEDOUT', + // syscall: 'connect', + // ... + // @ts-ignore + if (err.errno === 'ETIMEDOUT' && err.syscall === 'connect') { + return true; + } + if (!config.method) { return true; }