node async 仅在 node-lambda 内部调用第一个函数

node async only calls first function when inside node-lambda

使用像以下节点异步这样的原始节点脚本就可以正常工作:

async = require('async');

async.waterfall([
    function (c) {
        console.log(1);
        c(null);
    },        
    function (c) {
        console.log(2);
        c(null);
    }       
  ]);

以上当运行 via node test.js打印出来:

1
2

...如预期。

但是,如果我将代码放在 node-lambda 处理程序中:

var async = require('async');

exports.handler = function( event, context ) {
  console.log( "==================================");

  async.waterfall([
    function (c) {
        console.log(1);
        c(null);
    },        
    function (c) {
        console.log(2);
        c(null);
    }        
  ]);

  console.log( "==================================");
  context.done( );
}

当我运行./node_modules/.bin/node-lambda run

时只调用了第一个方法
==================================
1
==================================

我正在使用:

您正在使用异步代码。 显然,完成主函数handler执行的代码context.done( );和其他异步代码(瀑布中的第二个函数)无法执行,它没有足够的时间,因为主函数已经完成。