Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async.queue: throw error if called with a concurrency of 0 #714

Closed
LinusU opened this issue Feb 12, 2015 · 3 comments
Closed

async.queue: throw error if called with a concurrency of 0 #714

LinusU opened this issue Feb 12, 2015 · 3 comments
Labels

Comments

@LinusU
Copy link

LinusU commented Feb 12, 2015

I recently had this code:

var concurrency = os.cpus.length;

function doWork(opts, cb) {
  cb(null);
}

var queue = async.queue(doWork, concurrency);

Things queued never called the callback because os.cpus is a function that takes 0 arguments. Thus os.cpus.length returns 0 and the queue never does anything. The correct code would be os.cpus().length, notice the ().

Maybe it would be a good idea to throw an error to alert the user that the queue was initialised with 0 concurrency and thus never will run anything.

@LinusU LinusU changed the title async.queue: throw error if called wit a concurrency of 0 async.queue: throw error if called with a concurrency of 0 Feb 12, 2015
@aearly aearly added the bug label May 19, 2015
@VitoNordloh
Copy link
Contributor

PR #762

@VitoNordloh
Copy link
Contributor

Ah, i see that it's possible to change the concurrency after the initalisation.
I will update my PR later.

Edit: it's not possible to throw an error after the initalisation because we can't assert that the concurrency isn't zero since it's just a variable.
Especially in browser it would cause problems.

Further on we should assert that the concurrency isn't a negative value.

@aearly aearly closed this as completed in facb5cf May 20, 2015
@aearly
Copy link
Collaborator

aearly commented May 20, 2015

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants