Reputation: 413
Using a vanilla node script like the following node async works just fine:
async = require('async');
async.waterfall([
function (c) {
console.log(1);
c(null);
},
function (c) {
console.log(2);
c(null);
}
]);
The above when run via node test.js
prints out:
1
2
... as expected.
However if I place the code inside a node-lambda handler:
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( );
}
Only the first method is called when I run ./node_modules/.bin/node-lambda run
==================================
1
==================================
I'm using:
Upvotes: 3
Views: 255
Reputation: 8926
You are using asynchronous code.
Apparently that code context.done( );
to finish the executing of the main function handler
and other async code(second function in waterfall) cannot be executed, it did not have time enough, because the main function has been completed.
Upvotes: 1