Skip to content

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

@LinusU

Description

@LinusU

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions