asynchronous - async.series not working as expected Node.js -


var myfunction = function (param1,cb) {     async.series([         function(callback) {             func1(param1,callback);//an error occurred here. pass error callback.         },         function(callback) {             func2(param1,callback);         },         function(callback) {             func3(callback);         }     ],function(err, results) {  //its called when error occurred in of above function, remaining function keeps on executing in parallel.         if (typeof cb === "function") {             cb(err,results);         } }); }; 

if error occurred during func1, pass error callback.

the callback of async.series called when error occurred in of above function, remaining function keeps on executing in parallel.

i don't want other functions execute if error occured in function.

i think have use waterfall expected result.

var myfunction = function (param1,cb) { async.waterfall([     function(callback) {             callback(param1);         }     function(param1 ,callback) {         callback(param1);     },     function(param1 , callback) {          callback(null, 'result');     } ], function (err, result) {      if (typeof cb === "function") {             cb(err,results);         } }); } 

Comments