Friday, 26 May 2017

nodejs async series final callback fires before other functions

async.series([
    function(callback) {
        setTimeout(function(){ console.log("2"); }, 1000 * 10);
        callback();
    },
    function(callback) {
        console.log("1"); }, 1000 * 10);
        callback();
    },
], function(err) { 
      console.log("done");
 });

I am trying to execute above code. I expect the result to be
1
2
done

But I get the result as
1
done
2

Can someone help me on why the final callback is executing before series callbacks?



via Shravya Siluveru

No comments:

Post a Comment