newrelic/newrelic-lambda-extension

nodejs 14 lambda log duration over 120 seconds

Closed this issue · 8 comments

Description

[NR_NEXT] Extension shutdown after 121464ms ! And this causes our lambda timeout.

Steps to Reproduce

Expected Behavior

Relevant Logs / Console output

image

Your Environment

AWS nodejs 14 lambda runtime
TIP: # ( Include as many relevant details about your environment as possible. )
AWS Region: eu-west-1
Nodejs14
and Newrelic arn: arn:aws:lambda:eu-west-1:451483290750:layer:NewRelicNodeJS14X:84

Additional context

We have another similar report to this. It's a very difficult issue for us to reproduce, but we want to get to the bottom of it. We are having a hard time getting to the root cause with the information we have at the moment.

@xuetaofeng how frequently does this happen, and how frequently does your lambda function invoke? We believe this is some kind of race condition in high frequency lambda functions.

@xuetaofeng Are you setting the handler correctly? If not, this will cause a timeout. What is your handler set to? The handler must be set to newrelic-lambda-wrapper.handler which is a wrapped handler that is built into the .Net layer. https://docs.newrelic.com/docs/serverless-function-monitoring/aws-lambda-monitoring/enable-lambda-monitoring/instrument-your-own/

@iamemilio Running into this too but can't set the handler due to using ES Modules and following the guidelines here: https://github.com/newrelic/newrelic-lambda-layers/blob/993944fd0c8b6e6592672689f22aa744bffa752c/README.md#support-for-es-modules-nodejs

Any advice?

On deploying your function, don't set the function handler to our Node wrapper; instead, use your regular handler function, which you've wrapped with newrelic.setLambdaHandler().

@xuetaofeng are you using the pg postgres library? or MiddyJS?

Running into the same issue with Node14.x and pg + MiddyJS setup. Is there an example on how to handle lambda code with pg and middy library?

Now, Nodejs 14 is not supported layer. Please use the latest runtime. Thank you!