1

I have this very simple program and the output should be "foo" and then "baz", but for some reason "baz" isn't printed on the screen. What mistake am I making?

var async = require('async');

var q = async.queue(function (task, callback) {
    console.log(task.message);
}, 1);

q.push({ message : "foo" }, function (err) {});
q.push({ message : "baz" }, function (err) {});

2 Answers 2

4

You have to call callback in queue:

var q = async.queue(function (task, callback) {
    console.log(task.message);
    callback( );
}, 1);

This way it informs the queue, that it finished the task and the queue can jump to another one.

Sign up to request clarification or add additional context in comments.

Comments

1

You just forgott the

callback()

Try this it works for me:

var async = require('async');

var q = async.queue(function (task, callback) {
    console.log(task.message);
    callback();
}, 1);

q.push({ message : "foo" }, function (err) {});
q.push({ message : "baz" }, function (err) {});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.