Skip to content

Commit

Permalink
update algorythm
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Jul 2, 2024
1 parent 40bbdf5 commit 95ff6cf
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions lib/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@ const fetchH1 = h1NoCache({
rejectUnauthorized: false // By default skip auth check for all.
}).fetch;

const RETRY_ON_ERROR = [
'ECONNRESET',
const ERRORS_TO_RETRY = [
'ECONN',
'EAI_AGAIN',
'ECONNREFUSED',
'ENETUNREACH',
'HPE_INVALID_HEADER_TOKEN',
'HPE_INVALID_CONSTANT',
'ERR_SSL_SSLV3_ALERT_HANDSHAKE_FAILURE',
'ERR_SSL_UNSUPPORTED_PROTOCOL',
'ERR_SSL_TLSV1_ALERT_INTERNAL_ERROR',
'ERR_SSL_UNSAFE_LEGACY_REGENERATION_DISABLED',
'ERR_SSL_WRONG_VERSION_NUMBER'
'ENET',
'HPE_INVALID_',
'ERR_SSL_'
];

function doFetch(fetch_func, h1_fetch_func, options) {
Expand Down Expand Up @@ -104,10 +98,10 @@ function doFetch(fetch_func, h1_fetch_func, options) {
log(' -- doFetch h2 aborted error', uri);
resolve(doFetch(fetch_func, h1_fetch_func, Object.assign({}, options, {disable_http2: true})));

} else if (!options.retry_onerror && RETRY_ON_ERROR.indexOf(error.code) > -1) {
} else if (!options.stopRecursion && ERRORS_TO_RETRY.some(code => code.indexOf(error.code) > -1)) {

log(' -- doFetch ECONNRESET retry', error.code, uri);
resolve(doFetch(fetch_func, h1_fetch_func, Object.assign({}, options, {retry_onerror: true, disable_http2: true})));
resolve(doFetch(fetch_func, h1_fetch_func, Object.assign({}, options, {stopRecursion: true, disable_http2: true})));

} else {
if (error instanceof AbortError) {
Expand Down

0 comments on commit 95ff6cf

Please sign in to comment.