Skip to content

Commit

Permalink
Merge pull request #874 from storyblok/bugfix/hotfix-uncaught-promise
Browse files Browse the repository at this point in the history
fix: properly reject throttle queue errors
  • Loading branch information
alvarosabu authored Nov 22, 2024
2 parents 59be18a + 71d1c19 commit 5c183f9
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 5c183f9

Please sign in to comment.