From efb3ee18041e3d0e939a4956a51ea88d153982c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matt=C3=A9o=20Delabre?= Date: Sat, 4 Dec 2021 12:39:55 -0500 Subject: [PATCH] Fix exception pollution in retryable() --- lib/retry.mjs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/retry.mjs b/lib/retry.mjs index e5a35be..3e24d47 100644 --- a/lib/retry.mjs +++ b/lib/retry.mjs @@ -86,9 +86,20 @@ export const exclusive = (func, cooldown = 2000) => } else { - pending = pending - .then(() => sleep(cooldown)) - .then(() => func(...args)); + pending = (async () => + { + try + { + await pending; + } + catch + { + // Ignore errors from previous executions + } + + await sleep(cooldown); + return func(...args); + })(); } return pending;