Skip to content

Commit 5c183f9

Browse files
authored
Merge pull request #874 from storyblok/bugfix/hotfix-uncaught-promise
fix: properly reject throttle queue errors
2 parents 59be18a + 71d1c19 commit 5c183f9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/throttlePromise.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ function throttledQueue<T extends (...args: Parameters<T>) => ReturnType<T>>(
3030

3131
const x = queue.shift();
3232
if (x) {
33-
const res = await fn(...x.args);
34-
x.resolve(res);
33+
try {
34+
const res = await fn(...x.args);
35+
x.resolve(res);
36+
}
37+
catch (error) {
38+
x.reject(error);
39+
}
3540
}
3641

3742
const id = setTimeout(() => {

0 commit comments

Comments
 (0)