Compare commits

..

2 Commits

2 changed files with 17 additions and 5 deletions

View File

@ -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;

View File

@ -54,7 +54,7 @@ ${cache[videoId][1]}…`);
}
else if (cache[videoId][0] === statusError)
{
res.status(500).send('Error');
res.status(500).send(`Error: ${cache[videoId][1]}`);
}
else
{
@ -86,7 +86,8 @@ ${cache[videoId][1]}…`);
catch (err)
{
console.error(err);
cache[videoId] = [statusError];
console.log(`setting cache error to ${videoId}`)
cache[videoId] = [statusError, err.message];
}
}
});