Skip to content

Commit

Permalink
Merge pull request #260 from cognitedata/f1/stabilize_sdk_retry
Browse files Browse the repository at this point in the history
fix: retry ETIMEDOUT connection failures
  • Loading branch information
BugGambit authored Aug 9, 2019
2 parents 482ffec + b82736c commit 6239a50
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/retryRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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;
}
Expand Down

0 comments on commit 6239a50

Please sign in to comment.