JavaEar 专注于收集分享传播有价值的技术资料

AWS synchronous lambda to lambda invoke with nodejs

I have 2 lambda functions inside AWS.

Function A (FA), attempts to synchronously call Function B (FB). When FA attempts to call FB, FA will timeout. FA never reaches the callback method inside in FA and FB has no logs in cloudwatch to say it was called.

I have set up both functions to operate within the same region, same role, and no VPC (as I've read the VPC can cause issues, but have tried under the same VPC and subnet settings as well with no luck)

The user role has the following permissions associated

  • AWSLambdaExecute
  • AWSLambdaBasicExecutionRole
  • AWSLambdaRole

Funciton A

exports.handler = (event, context, callback) => {
    var aws = require('aws-sdk');
    var lambda = new aws.Lambda({
      region: 'ap-southeast-2'

      FunctionName: 'async-receiver-test'
    }, function(error, data) {
        console.log('inside return function');
      if (error) {
         context.done('error', error);

Function B - (name => async-receiver-test)

exports.handler = (event, context, callback) => {
    var eventItem = {id : 53148, name : "Let's get testing"};
    callback(null, eventItem);

Running Function A inside the console returns

REPORT RequestId: 2db82333-f9c3-11e6-8160-93bd7ddf5b19 Duration: 3000.43 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 25 MB
2017-02-23T12:25:39.363Z 2db82333-f9c3-11e6-8160-93bd7ddf5b19 Task timed out after 3.00 seconds

Running Function B inside the console (Duration: 14.36 ms)

{ "id": 53148, "name": "Let's get testing" }

So it's not an issue with FB from what i can tell, but for some reason there is no response when invoked from FA.


  1. So it turns out by increasing the timeout on FA to 10 seconds the invoke will work. I never thought that FA would need anything longer than the default timeout to call FB that took 2ms to run. It did however only require a longer timeout for the first call as it was taking over the 3 seconds to run, any subsequent calls were running in the 100ms range.

    Still have a problem when I add the VPC settings back in but now I know that invoke is working I can tackle that problem which i believe has been solved here