From dfba8bd15f7e690e6890655a0cbcbadff1daeded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:32:35 -0500 Subject: [PATCH] feat: better blitz fetch error management --- src/core/blitz/fetchBlitz.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/blitz/fetchBlitz.ts b/src/core/blitz/fetchBlitz.ts index 5ac7a256d..566f1715b 100644 --- a/src/core/blitz/fetchBlitz.ts +++ b/src/core/blitz/fetchBlitz.ts @@ -17,7 +17,7 @@ async function manageQueue() { if (queue.length > 0 && inProgress < MAX_CALLS_PER_SECOND) { inProgress++; - setTimeout(() => { + const timeout = setTimeout(() => { inProgress--; manageQueue(); }, 1000); @@ -32,6 +32,10 @@ async function manageQueue() { if (data.status === 'ok') { resolve(data.data); } else { + clearTimeout(timeout); + inProgress--; + manageQueue(); + throw new Error(`Wargaming response error status: "${data.status}"`, { cause: `Message: "${data.error.message}"\nURL: "${url}"`, });