-
Notifications
You must be signed in to change notification settings - Fork 58
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
[Bug] Issue using aws-otel-nodejs in Lambda #99
Comments
Seems like it could be related to aws/aws-xray-sdk-node#433 which is an |
Thanks @melek-inception - I have filed an issue upstream on whether it's possible to monkey patch libraries created with esbuild or CDK (not sure which is causing it to be non-redefinable). |
w.r.t. the original For the newer |
For anyone facing the issue related to For the lambda handler, instead of export const handler = () => {
// removed for brevity
}; Do this const handler = () => {
// removed for brevity
};
module.exports = { handler } |
@longility , you beat me to update the GitHub issue 💯 The error seems to be linked to the Hope this help! |
@willarmiros , I will close the ticket unless you think of a different workaround. |
This change adds a short blurb about requirements for users who are using esbuild. As discussed in aws-observability/aws-otel-lambda#99 there is a quirk of esbuild that causes exported functions using the `export` keyword to be marked immutable in the transpiled JS. As a result, you must use `module.exports` instead, which is passed along by the esbuild transpilation process unscathed.
Just wanted to add a note for anyone else dealing with this issue, we've also noticed other factors that cause exports to be immutable (and trigger the In our case, it was an ESBuild plugin: Anything in the build process that causes exports to be immutable (like using |
Context
I am trying to configure ADOT and use it with the current implementation of Lambda through AWS CDK. AWS CDK offers a ready-to-use NodeJS lambda constructs
@aws-cdk/aws-lambda-nodejs
.Unfortunately, it seems that there is an error/conflict between the
otel-handler
and the way@aws-cdk/aws-lambda-nodejs
builds the lambda function. I am not sure if it is related toesbuild
or not.Configuration
I am using the following code to create a Lambda function.
Error
The Lambda function is deployed properly. However, when running the function, I receive the following error:
I added a dummy
package.json
to the project, and now I receive the same error in #97 .The text was updated successfully, but these errors were encountered: