3

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:

  • async 1.5.2,
  • node 5.5.0
  • node-lambda 0.1.5

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@keithgould I've update the answer. Try to remove context.done( ); to test
Boom! That was it @isvforall. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.