如何停止在node.js异步错误中执行瀑布? [英] How to stop executing waterfall on error in async of node.js?
本文介绍了如何停止在node.js异步错误中执行瀑布?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有瀑布方法的异步模块.
I am using async module with waterfall method.
async.waterfall([
function(callback) {
...
callback(err);
},
function(result, callback) {
console.log("This function should not be executed");
}
],
function(err) {
if (err) {
next(err);
return;
}
}
);
但是第二个功能总是执行.如何预防呢?
But the second function always execute. How to prevent it?
推荐答案
尝试添加return
async.waterfall([
function(callback) {
...
return callback(err); //note return here
},
function(result, callback) {
console.log("This function should not be executed");
}
],
function(err) {
if (err) {
next(err);
return;
}
}
);
这篇关于如何停止在node.js异步错误中执行瀑布?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文