datadog-lambda-js: TypeError - handler is not a function
Expected Behavior
Lambda layer functions correctly
Actual Behavior
As of 5am BST the datadog lambda layer versions 62 and 64 for node 14.x in us-east-1 are intermittently exhibiting a type error on lambda execution. Same layer in eu-west-1 with same code is not exhibiting the issue. The lambda functioned correctly for 18 hours with version 62 of the layer then started getting the type error which persisted for 90 minutes until same code was redeployed with version 64 of the layer. This then worked for 2 hours before giving the same type error and has done so for the last hour.
Steps to Reproduce the Problem
- Apply the layer on a lambda in us-east-1
Specifications
- Datadog Lambda Layer version: 62 & 64
- Node version: 14.x
Stacktrace
{
"errorType": "TypeError",
"errorMessage": "handler is not a function",
"stack": [
"TypeError: handler is not a function",
" at /opt/nodejs/node_modules/datadog-lambda-js/utils/handler.js:148:25",
" at Object.<anonymous> (/opt/nodejs/node_modules/datadog-lambda-js/index.js:168:62)",
" at step (/opt/nodejs/node_modules/datadog-lambda-js/index.js:44:23)",
" at Object.next (/opt/nodejs/node_modules/datadog-lambda-js/index.js:25:53)",
" at /opt/nodejs/node_modules/datadog-lambda-js/index.js:19:71",
" at new Promise (<anonymous>)",
" at __awaiter (/opt/nodejs/node_modules/datadog-lambda-js/index.js:15:12)",
" at /opt/nodejs/node_modules/datadog-lambda-js/index.js:162:108",
" at /opt/nodejs/node_modules/dd-trace/packages/dd-trace/src/tracer.js:97:56",
" at /opt/nodejs/node_modules/dd-trace/packages/dd-trace/src/tracer.js:48:56"
]
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 23
- Comments: 58 (16 by maintainers)
Sorry for the late response, we noticed that certain Node14.x Lambda functions deployed in us-east-1 were observing intermittent errors (“handler is not a function”) between 7:20PM October 13th EDT and 8:00AM October 14th EDT. We are actively investigating the root cause with the AWS Lambda team, and will share the results with the community as soon as possible. Please subscribe this issue or contact Datadog support (support@datadoghq.com) for the investigation results and additional technical details.
I opened a support case with AWS and the initial response says the internal team “are actively investigating the increased errors when using Node.JS 14 in the US-EAST-1 Region.” so this may be an AWS issue. I recreated the lambda with the same code and version of the datadog layer and haven’t see any issues for last hour or so.
Support got back to us.
Ok. Found a workaround for now. the cdk construct is changing the handlers by injecting
/opt/nodejs/node_modules/datadog-lambda-js/handler.handlerand replace it withDD_LAMBDA_HANDLERvalue (the original handler).by changing the lambda handler to the local file path + function solve the issue (the value you have in
DD_LAMBDA_HANDLER).we don’t see more error the error no more
If it helps, my team has experienced the very same issue in ca-central-1 as well
@Kamitenshi have you tried rebuild your image using the latest of
public.ecr.aws/lambda/nodejs:14and redeploy your function?Since the issue has been fixed, I’m going to close this thread. We are writing a postmortem next week, please contact support@datadoghq.com for a copy as you desire. Again, very sorry for everyone’s loss and inconvenience, we are doing everything we can to prevent similar issues from happening again! Thanks for your understanding and help! 🙇
LATEST UPDATES [12PM 10/15/21 EDT]: We no longer observe issues in
ca-central-1or functions usingpublic.ecr.aws/lambda/nodejs:14. No customer is expected to experience this issue at this point time. If that’s not the case, please let us know.@Kamitenshi and for whoever using container images, try use an older version of the base image by AWS
public.ecr.aws/lambda/nodejs:14.2021.10.07.14-x86_64. According to our tests, any version after this one still experience the issue.@alexis-caylent I don’t think
aws:states:opt-outis related. Are you currently experiencing the same error inca-central-1?Same issue has been happening for us with a simple lambda for the last 12 hours - no datadog or layers. Stumbled upon this searching the internet for similar cases.
We’re experiencing this too and can confirm the workaround that @lielran posted above worked for us.
So is the problem here that the DD layer is generating the
DD_LAMBDA_HANDLERenvironment variable using the relative path for the layer instead of the literal path for the bundled lambda? Did AWS indicate that this is something they actually intend to fix, or is the update they made going to be the new method for bundling to which we need to adapt?Same for us, we had Node 14.x and the layer
49. I switched to64just to make sure it wasn’t the layer version, but it quickly became evident that the version didn’t matter. Since there was no code change on our side before and after the errors started showing up, we believe it’s infra related.The layer is still there, and you can’t modify it AFAIK so this must be AWS.
We opened a ticket with AWS. I think they’re are doing some changes to Lambda and this might be related
Amazing @lielran that really seems to work - I think it’s the only thing I haven’t tried, I was going to just rip off datadog complitely