Skip to content

Commit

Permalink
fix(aws-serverless): Fix build of lambda layer (#12083)
Browse files Browse the repository at this point in the history
We previously adjusted our lambda layer auto initialization in
#12017. This
unfortunately changed the build output of the `awslambda-auto`
bootstrapping script which required a package that isn't included in the
layer (`@sentry/node`). This PR fixes the `awslambda-auto` file; local
testing showed no more imports from `@sentry/node`.

fixes #12074
  • Loading branch information
Lms24 committed May 16, 2024
1 parent ac94e3e commit 7ce2f20
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/aws-serverless/rollup.aws.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default [
sourcemap: false,
},
},
preserveModules: false,
}),
// We only need one copy of the SDK, and we pick the minified one because there's a cap on how big a lambda function
// plus its dependencies can be, and we might as well take up as little of that space as is necessary. We'll rename
Expand Down
9 changes: 4 additions & 5 deletions packages/aws-serverless/src/awslambda-auto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { getDefaultIntegrations as getNodeDefaultIntegrations } from '@sentry/node';
import { init, tryPatchHandler } from './sdk';
import * as Sentry from './index';

const lambdaTaskRoot = process.env.LAMBDA_TASK_ROOT;
if (lambdaTaskRoot) {
Expand All @@ -8,12 +7,12 @@ if (lambdaTaskRoot) {
throw Error(`LAMBDA_TASK_ROOT is non-empty(${lambdaTaskRoot}) but _HANDLER is not set`);
}

init({
Sentry.init({
// We want to load the performance integrations here, if the tracesSampleRate is set for the layer in env vars
// Sentry node's `getDefaultIntegrations` will load them if tracing is enabled,
// which is the case if `tracesSampleRate` is set.
// We can safely add all the node default integrations
integrations: getNodeDefaultIntegrations(
integrations: Sentry.getDefaultIntegrations(
process.env.SENTRY_TRACES_SAMPLE_RATE
? {
tracesSampleRate: parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE),
Expand All @@ -22,7 +21,7 @@ if (lambdaTaskRoot) {
),
});

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

0 comments on commit 7ce2f20

Please sign in to comment.