@elastic.io/component-commons-library
Advanced tools
Comparing version 3.0.1-dev.3 to 3.0.1-dev.4
@@ -10,4 +10,4 @@ "use strict"; | ||
minValue: 0, | ||
defaultValue: 2, | ||
maxValue: 4 | ||
defaultValue: 3, | ||
maxValue: 5 | ||
}; | ||
@@ -17,4 +17,4 @@ const ENV_API_RETRIES_COUNT = process.env.API_RETRIES_COUNT ? parseInt(process.env.API_RETRIES_COUNT, 10) : exports.API_RETRIES_COUNT.defaultValue; | ||
minValue: 500, | ||
defaultValue: 10000, | ||
maxValue: 15000 | ||
defaultValue: 15000, | ||
maxValue: 20000 | ||
}; | ||
@@ -36,3 +36,3 @@ const ENV_API_REQUEST_TIMEOUT = process.env.API_REQUEST_TIMEOUT ? parseInt(process.env.API_REQUEST_TIMEOUT, 10) : exports.API_REQUEST_TIMEOUT.defaultValue; | ||
const exponentialDelay = (currentRetries) => { | ||
const maxBackoff = 10000; | ||
const maxBackoff = 20000; | ||
const delay = (2 ** currentRetries) * 100; | ||
@@ -74,3 +74,3 @@ const randomSum = delay * 0.2 * Math.random(); // 0-20% of the delay | ||
if (((_a = err.response) === null || _a === void 0 ? void 0 : _a.status) < 500) { | ||
throw new Error((0, exports.getErrMsg)(err.response)); | ||
throw error; | ||
} | ||
@@ -84,4 +84,4 @@ this.logger.info(`URL: "${options.url}", method: ${options.method}, Error message: "${err.message}"`); | ||
} | ||
throw new Error(error.message); | ||
throw error; | ||
}; | ||
exports.axiosReq = axiosReq; |
{ | ||
"name": "@elastic.io/component-commons-library", | ||
"version": "3.0.1-dev.3", | ||
"version": "3.0.1-dev.4", | ||
"description": "Library for most common component development cases", | ||
@@ -63,2 +63,2 @@ "author": { | ||
"license": "Apache-2.0" | ||
} | ||
} |
@@ -10,4 +10,4 @@ import axios, { AxiosResponse, AxiosInstance, AxiosRequestConfig } from 'axios'; | ||
minValue: 0, | ||
defaultValue: 2, | ||
maxValue: 4 | ||
defaultValue: 3, | ||
maxValue: 5 | ||
} as const; | ||
@@ -18,4 +18,4 @@ const ENV_API_RETRIES_COUNT = process.env.API_RETRIES_COUNT ? parseInt(process.env.API_RETRIES_COUNT, 10) : API_RETRIES_COUNT.defaultValue; | ||
minValue: 500, | ||
defaultValue: 10000, | ||
maxValue: 15000 | ||
defaultValue: 15000, | ||
maxValue: 20000 | ||
} as const; | ||
@@ -38,3 +38,3 @@ const ENV_API_REQUEST_TIMEOUT = process.env.API_REQUEST_TIMEOUT ? parseInt(process.env.API_REQUEST_TIMEOUT, 10) : API_REQUEST_TIMEOUT.defaultValue; | ||
export const exponentialDelay = (currentRetries: number) => { | ||
const maxBackoff = 10000; | ||
const maxBackoff = 20000; | ||
const delay = (2 ** currentRetries) * 100; | ||
@@ -74,3 +74,3 @@ const randomSum = delay * 0.2 * Math.random(); // 0-20% of the delay | ||
if (err.response?.status < 500) { | ||
throw new Error(getErrMsg(err.response)); | ||
throw error; | ||
} | ||
@@ -84,3 +84,3 @@ this.logger.info(`URL: "${options.url}", method: ${options.method}, Error message: "${err.message}"`); | ||
} | ||
throw new Error(error.message); | ||
throw error; | ||
}; |
1344597