From 562f879df5f1fd2aa6d2b411e67357b78a9bc249 Mon Sep 17 00:00:00 2001 From: Vito Alexander Nordloh Date: Wed, 20 May 2015 23:22:52 +0200 Subject: [PATCH] intercept queue concurrency of 0 --- lib/async.js | 3 +++ test/test-async.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/async.js b/lib/async.js index 47ab5a723..81916fd89 100644 --- a/lib/async.js +++ b/lib/async.js @@ -886,6 +886,9 @@ if (concurrency === undefined) { concurrency = 1; } + else if(concurrency === 0) { + throw new Error('Concurrency must not be zero'); + } function _insert(q, data, pos, callback) { if (!q.started){ q.started = true; diff --git a/test/test-async.js b/test/test-async.js index 6f6a74153..64c33f986 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -2453,6 +2453,13 @@ exports['queue default concurrency'] = function (test) { }; }; +exports['queue zero concurrency'] = function(test){ + test.throws(function () { + async.queue(function (task, callback) {}, 0); + }); + test.done(); +}; + exports['queue error propagation'] = function(test){ var results = [];