Skip to content

Commit

Permalink
fix: properly reject throttle queue errors
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Nov 22, 2024
1 parent 59be18a commit 71d1c19
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/throttlePromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ function throttledQueue<T extends (...args: Parameters<T>) => ReturnType<T>>(

const x = queue.shift();
if (x) {
const res = await fn(...x.args);
x.resolve(res);
try {
const res = await fn(...x.args);
x.resolve(res);
}
catch (error) {
x.reject(error);
}
}

const id = setTimeout(() => {
Expand Down

0 comments on commit 71d1c19

Please sign in to comment.