2

Trying to test a basic lambda locally that runs fine in AWS but I keep getting

No response from invoke container for MyLambdaXXXXXXXX

'tsc' and 'synth' run fine and I get a proper cdk.out

The invoke command is

sam local invoke --region us-east-1 --env-vars .env.json -t ./cdk.out/my-project.template.json -e events/example.event.json MyLambdaXXXXXXXX

There is no api or anything docker related that I find in similar questions like the few listed below.

The only output I see is this (no logs from even the first line of the lambda)

Invoking index.execute (nodejs14.x)
Skip pulling image and use local one: public.ecr.aws/sam/emulation-nodejs14.x:rapid-1.46.0-x86_64.

Mounting /path-to-my-project/my-project/cdk.out/asset.aaaaa9999999cd5a9f38e9c4e503cc9c9bdf8ccdc8f9999991b12b6161e99999 as /var/task:ro,delegated inside runtime container
No response from invoke container for MyLambdaXXXXXXXX

Process finished with exit code 0

If it matters my handler structure for my lambda is async

export const execute = async (sqsEvent: SQSEvent): Promise<PutEventsCommandOutput> => {
  await someAsyncStuffWithDocumentDB()
}

And I'm using NodejsFunction cdk with bundling like this

bundling: {
  minify: true,
  sourceMap: true,
  externalModules: ['aws-lambda', 'aws-sdk'],
  loader: { '.pem': 'file' }, // cert for DocumentDB
},
canpan14
  • 1,181
  • 1
  • 14
  • 36
  • Are you using any Layers with your Lambda function? I was encountering a very similar error and removing the Layers param from my template.yaml resolved the issue. Otherwise, seeing your template file might be helpful here as well. – bcaspar Apr 22 '22 at 20:15
  • Nope (although I plan to in the future). Right now we believe it's something specific with my computer (running macOS on the 12.3.1). Others are not having the same issue when running my code. It sometimes works if I just keep trying so I figure there might be some async mistakes in the lambda causing it (I can't find any but still looking). When I make the entry point method not be async it runs fine (I need async but it was just for a sanity test). – canpan14 Apr 25 '22 at 12:49

1 Answers1

1

I came across similar issue and solved it by increasing 'Timeout' from 3 to 10 in [template.yaml] file. When you import(or require) a number of npm packages, the loading time can be pretty long, maybe 3 secs are not enough. Just my guess

Zander Hsu
  • 19
  • 1
  • 4