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 = [];