I have a large node.js application that heavily uses the async.js module.
I have a lot of code like this:
async.series([
function(callback){
sql.update(query, callback);
},
function(callback){
if (something){
sql.update(query2, callback);
}
else{
callback(null);
}
}
]);
The big problem is the synchronous callback in the else statement. I read a while back that you should not do that with async.js as it could cause unexpected results, but I'm not sure what the best alternative is. I read that I should use process.nextTick in some places, but now I'm reading that we should not use that and it should be setImmediate.
Can someone point me in the right direction? Thanks!
callback
should be null if there is no error otherwise the.series
call would just exit with the error. try debugging it withconsole.trace()
, breakpoints and more output. – Staminody