From a9aba8b06be6d10d9dad4c4fe085189d67a8a01c Mon Sep 17 00:00:00 2001 From: 1computer1 Date: Tue, 21 May 2019 11:38:26 -0400 Subject: [PATCH] Fix queue limit off-by-one --- src/struct/Queue.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/struct/Queue.js b/src/struct/Queue.js index 4c89d5f..511f479 100644 --- a/src/struct/Queue.js +++ b/src/struct/Queue.js @@ -12,7 +12,7 @@ class Queue { enqueue(task) { return new Promise((resolve, reject) => { this.tasks.push({ task, resolve, reject }); - if (this.ongoing <= this.limit) { + if (this.ongoing < this.limit) { this.process(); } }); @@ -29,7 +29,7 @@ class Queue { } this.ongoing--; - while (this.ongoing <= this.limit && this.tasks.length > 0) { + while (this.ongoing < this.limit && this.tasks.length > 0) { this.process(); } }