Skip to content

Commit

Permalink
intercept queue concurrency of 0
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoNordloh committed May 20, 2015
1 parent 138b0a2 commit 562f879
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions test/test-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

Expand Down

0 comments on commit 562f879

Please sign in to comment.