Skip to content

Commit 7ce2f20

Browse files
authored
fix(aws-serverless): Fix build of lambda layer (#12083)
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
1 parent ac94e3e commit 7ce2f20

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/aws-serverless/rollup.aws.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default [
1515
sourcemap: false,
1616
},
1717
},
18+
preserveModules: false,
1819
}),
1920
// 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
2021
// plus its dependencies can be, and we might as well take up as little of that space as is necessary. We'll rename
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { getDefaultIntegrations as getNodeDefaultIntegrations } from '@sentry/node';
2-
import { init, tryPatchHandler } from './sdk';
1+
import * as Sentry from './index';
32

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

11-
init({
10+
Sentry.init({
1211
// We want to load the performance integrations here, if the tracesSampleRate is set for the layer in env vars
1312
// Sentry node's `getDefaultIntegrations` will load them if tracing is enabled,
1413
// which is the case if `tracesSampleRate` is set.
1514
// We can safely add all the node default integrations
16-
integrations: getNodeDefaultIntegrations(
15+
integrations: Sentry.getDefaultIntegrations(
1716
process.env.SENTRY_TRACES_SAMPLE_RATE
1817
? {
1918
tracesSampleRate: parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE),
@@ -22,7 +21,7 @@ if (lambdaTaskRoot) {
2221
),
2322
});
2423

25-
tryPatchHandler(lambdaTaskRoot, handlerString);
24+
Sentry.tryPatchHandler(lambdaTaskRoot, handlerString);
2625
} else {
2726
throw Error('LAMBDA_TASK_ROOT environment variable is not set');
2827
}

0 commit comments

Comments
 (0)