Fix exception pollution in retryable()

This commit is contained in:
Mattéo Delabre 2021-12-04 12:39:55 -05:00
parent 13e49d9a59
commit efb3ee1804
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
1 changed files with 14 additions and 3 deletions

View File

@ -86,9 +86,20 @@ export const exclusive = (func, cooldown = 2000) =>
} }
else else
{ {
pending = pending pending = (async () =>
.then(() => sleep(cooldown)) {
.then(() => func(...args)); try
{
await pending;
}
catch
{
// Ignore errors from previous executions
}
await sleep(cooldown);
return func(...args);
})();
} }
return pending; return pending;