Fix queue limit off-by-one

This commit is contained in:
1computer1 2019-05-21 11:38:26 -04:00
parent 2cdec2aa2f
commit a9aba8b06b

View file

@ -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();
}
}