diff options
-rw-r--r-- | lib/internal/queue.js | 4 | ||||
-rw-r--r-- | test/queue.js | 6 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/internal/queue.js b/lib/internal/queue.js index fdbabbc..fffea99 100644 --- a/lib/internal/queue.js +++ b/lib/internal/queue.js @@ -115,8 +115,10 @@ export default function queue(worker, concurrency, payload) { trigger('unsaturated') } - if (q.idle()) { + if (q.idle() && !drainScheduled) { + drainScheduled = true trigger('drain') + drainScheduled = false } q.process(); }; diff --git a/test/queue.js b/test/queue.js index bd71b05..c99380e 100644 --- a/test/queue.js +++ b/test/queue.js @@ -690,8 +690,8 @@ describe('queue', function(){ }); it('should not schedule another drain call if one is running', (done) => { - const q = async.queue(() => { - throw new Error('should not be called') + const q = async.queue((task, cb) => { + cb(null, task); }) let numCalled = 0 @@ -702,7 +702,7 @@ describe('queue', function(){ numCalled++ q.push([]) }) - q.push([]) + q.push('foo') setTimeout(() => { expect(numCalled).to.equal(1) |