Skip to content

fix(aws-serverless): Only auto-patch handler in CJS when loading awslambda-auto #12392

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

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/aws-serverless/src/awslambda-auto.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Important: This file cannot import anything other than the index file below.
// This is the entry point to the lambda layer, which only contains the entire SDK bundled into the index file
import * as Sentry from './index';

const lambdaTaskRoot = process.env.LAMBDA_TASK_ROOT;
Expand All @@ -21,7 +23,9 @@ if (lambdaTaskRoot) {
),
});

Sentry.tryPatchHandler(lambdaTaskRoot, handlerString);
if (typeof require !== 'undefined') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fwiw, this is the same check we use in our isCjs utility within the SDK. I just can't import it here because this doesn't play well with the lambda layer being bundled into the index file imported on top.

Sentry.tryPatchHandler(lambdaTaskRoot, handlerString);
}
} else {
throw Error('LAMBDA_TASK_ROOT environment variable is not set');
}
Loading