From 71d1c1940e2a270e1f10a0a0e323594f36e1337a Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Fri, 22 Nov 2024 17:17:27 +0100 Subject: [PATCH] fix: properly reject throttle queue errors --- src/throttlePromise.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/throttlePromise.ts b/src/throttlePromise.ts index 45cbc583..b80507a9 100644 --- a/src/throttlePromise.ts +++ b/src/throttlePromise.ts @@ -30,8 +30,13 @@ function throttledQueue) => ReturnType>( 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(() => {