From 39e17419d79a45e8f2947f7a921036f40dc6e030 Mon Sep 17 00:00:00 2001 From: Nulo Date: Wed, 29 Nov 2023 00:33:28 -0300 Subject: [PATCH] reintentar menos veces y evitar situaciones en donde se reintente todo al mismo tiempo --- download_json.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/download_json.js b/download_json.js index d67e529..d227c31 100644 --- a/download_json.js +++ b/download_json.js @@ -191,13 +191,13 @@ async function downloadDistWithRetries(job, attempts = 0) { await wait(15000); return await downloadDistWithRetries(job, attempts + 1); } - // si no fue un error de http, reintentar hasta 5 veces con 5 segundos de por medio + // si no fue un error de http, reintentar hasta 3 veces con 5 segundos de por medio else if ( !(error instanceof StatusCodeError) && !(error instanceof TooManyRedirectsError) && - attempts < 10 + attempts < 3 ) { - await wait(5000); + await wait(5000 + Math.random() * 10000); return await downloadDistWithRetries(job, attempts + 1); } else throw error; }