From 2b487defa873ae1c3f38d8b9566eff51c762bd13 Mon Sep 17 00:00:00 2001 From: bendtherules Date: Sat, 7 Feb 2026 10:05:49 +0530 Subject: [PATCH] Fix finally edge case --- solutions/async-scheduler.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/solutions/async-scheduler.js b/solutions/async-scheduler.js index acbf368..e65ac56 100644 --- a/solutions/async-scheduler.js +++ b/solutions/async-scheduler.js @@ -13,7 +13,6 @@ class TaskScheduler { resolve, reject, }); - this._processQueue(); return promise; } @@ -32,11 +31,14 @@ class TaskScheduler { // Ensure taskFn errors are captured as rejections const taskPromise = Promise.resolve().then(() => taskFn()); - taskPromise.then(resolve, reject); - taskPromise.finally(() => { - this.runningCount--; - this._processQueue(); - }); + taskPromise + .then(resolve, reject); + taskPromise + .catch(() => {}) + .finally(() => { + this.runningCount--; + this._processQueue(); + }); } }