mirror of
https://github.com/bendtherules/JSQuestions.git
synced 2026-08-18 13:53:51 +00:00
Fix finally edge case
This commit is contained in:
@@ -13,7 +13,6 @@ class TaskScheduler {
|
||||
resolve,
|
||||
reject,
|
||||
});
|
||||
|
||||
this._processQueue();
|
||||
return promise;
|
||||
}
|
||||
@@ -32,8 +31,11 @@ class TaskScheduler {
|
||||
|
||||
// Ensure taskFn errors are captured as rejections
|
||||
const taskPromise = Promise.resolve().then(() => taskFn());
|
||||
taskPromise.then(resolve, reject);
|
||||
taskPromise.finally(() => {
|
||||
taskPromise
|
||||
.then(resolve, reject);
|
||||
taskPromise
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
this.runningCount--;
|
||||
this._processQueue();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user