node async.parallel并行执行 报Callback was already called错误怎样解决

node async.parallel并行执行 报Callback was already called错误怎样解决?

 async.parallel([
            function (callback) {
                self.getNewsByTime().then(function (newsData) {
                    self.emit('addToLife', newsData, extras, function (err, extras) {
                        if (err){
                            next(err, null)
                        } else {
                            next(null, extras)
                        }
                    });
                });
            },
            function (callback) {
                self.getUpdateNewsByTime().then(function (updateNewsData) {
                    if (updateNewsData.length>0) {
                        self.emit('updateToLife', updateNewsData, extras, function (err, extras) {
                            if (err){
                                next(err, null)
                            } else {
                                next(null, extras)
                            }
                        });
                    }
                });
            },
             function (callback) {
                self.getDeleteNewsByTime().then(function (deleteNewsData) {
                    if (deleteNewsData.length>0){
                        self.emit('deleteFromLife', deleteNewsData, extras, function (err, extras) {
                            if (err){
                                next(err, null)
                            } else {
                                next(null, extras)
                            }
                        });
                    }
                });
             }
        ],
        function (err, results) {
            console.log(results);
        })
阅读 4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题