diff options
Diffstat (limited to 'client/node_modules/got/dist/source/core/calculate-retry-delay.js')
-rw-r--r-- | client/node_modules/got/dist/source/core/calculate-retry-delay.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/client/node_modules/got/dist/source/core/calculate-retry-delay.js b/client/node_modules/got/dist/source/core/calculate-retry-delay.js new file mode 100644 index 0000000..99f604a --- /dev/null +++ b/client/node_modules/got/dist/source/core/calculate-retry-delay.js @@ -0,0 +1,29 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.retryAfterStatusCodes = void 0; +exports.retryAfterStatusCodes = new Set([413, 429, 503]); +const calculateRetryDelay = ({ attemptCount, retryOptions, error, retryAfter }) => { + if (attemptCount > retryOptions.limit) { + return 0; + } + const hasMethod = retryOptions.methods.includes(error.options.method); + const hasErrorCode = retryOptions.errorCodes.includes(error.code); + const hasStatusCode = error.response && retryOptions.statusCodes.includes(error.response.statusCode); + if (!hasMethod || (!hasErrorCode && !hasStatusCode)) { + return 0; + } + if (error.response) { + if (retryAfter) { + if (retryOptions.maxRetryAfter === undefined || retryAfter > retryOptions.maxRetryAfter) { + return 0; + } + return retryAfter; + } + if (error.response.statusCode === 413) { + return 0; + } + } + const noise = Math.random() * 100; + return ((2 ** (attemptCount - 1)) * 1000) + noise; +}; +exports.default = calculateRetryDelay; |