Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 6.82.0 breaks AWS RIC support #305

Closed
cRicateau opened this issue Sep 2, 2022 · 1 comment · Fixed by #307
Closed

Version 6.82.0 breaks AWS RIC support #305

cRicateau opened this issue Sep 2, 2022 · 1 comment · Fixed by #307
Assignees

Comments

@cRicateau
Copy link

cRicateau commented Sep 2, 2022

Expected Behavior

dd-lambda-js works with container-based lambdas that are build using AWS Lambda NodeJS Runtime Interface Client
. AWS lambda RIC allows to create custom docker images to use them for lambda, which is useful when you need to create a lambda based on your own docker image.

Actual Behavior

Since version 6.82.0 (6.81.0 is fine), the file node_modules/datadog-lambda-js/dist/handler.js is not bundled anymore in the npm package. However AWS lambda ric doesn't seem to work without it, it throws an error Cannot find module 'handler'.
The code that throws is that one https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/blob/main/src/utils/UserFunction.ts#L106

Because of this, all custom container based lambdas cannot be instrumented with version > 6.81.0.
So the problem is not really about the code itself, but the way it integrates with AWS RIC.

Steps to Reproduce the Problem

  1. Create a dummy lambda with AWS RIC => Follow the AWS RIC tuto (see doc in https://www.npmjs.com/package/aws-lambda-ric)
  2. Add datadog docker layer + [email protected] => Follow the datadog tuto https://docs.datadoghq.com/serverless/installation/nodejs/?tab=containerimage
  3. Build the container image
  4. Run the image (I recommend adding AWS RIE cf https://docs.aws.amazon.com/gb_gb/lambda/latest/dg/images-test.html) (warning about this that will happen on version 6.81.0 Handler hangs when using datadog-agent from the Datadog-Extension layer (version 19,21) aws/aws-lambda-runtime-interface-emulator#65, for version 6.82.0 the problem doesn't happen since it throws before)
  5. See error by calling running the lambda curl --request POST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}' --header 'Content-Type: application/json' if you have done step 4

Specifications

  • Datadog Lambda Layer version: 6.82.0
  • Node version: 16.16

Stacktrace

From AWS lambda RIC:

{
"errorType":"Runtime.ImportModuleError",
"errorMessage":"Error: Cannot find module 'handler'\nRequire stack:\n- /function/node_modules/aws-lambda-ric/lib/utils/UserFunction.js\n
}
@astuyve
Copy link
Contributor

astuyve commented Sep 2, 2022

Hi @cRicateau - thanks for reaching out.

I'm unsure why that file was removed only in 6.82 but not earlier, as it was removed from this repository in 6.76.

You could probably copy it in your docker image as a workaround:

RUN cp node_modules/datadog-lambda-js/dist/handler.cjs node_modules/datadog-lambda-js/dist/handler.js

But I can re-add it and cut a new release. Thanks!

@astuyve astuyve self-assigned this Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants