Skip to content

Conversation

@andreiborza
Copy link
Member

Our recommended approach for the aws sdk is to use our Lambda layer. When the Lambda layer is used, it would previously automatically set up the layer extension. This can be disabled by setting useLayerExtension: false during init, but when using the layer with our auto-wrapping as per recommendation, it wasn't possible to opt out of using the extension.

This PR adds SENTRY_LAYER_EXTENSION that can be used to opt out of the extension.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

LGTM! Two minor nits, both optional :)

Comment on lines 443 to 472
test('should support various falsy values (0, no, off)', () => {
const falsyValues = ['0', 'no', 'off', 'n', 'f'];

falsyValues.forEach(value => {
mockGetSDKSource.mockReturnValue('aws-lambda-layer');
process.env.SENTRY_LAYER_EXTENSION = value;

init({});

expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith(
expect.objectContaining({
useLayerExtension: false,
}),
);
});
});

test('should fall back to default behavior when SENTRY_LAYER_EXTENSION is not set', () => {
mockGetSDKSource.mockReturnValue('aws-lambda-layer');
const options: AwsServerlessOptions = {};

init(options);

expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith(
expect.objectContaining({
useLayerExtension: true,
tunnel: 'http://localhost:9000/envelope',
}),
);
});
Copy link
Member

Choose a reason for hiding this comment

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

l: no strong opinion so feel free to ignore but: I don't think we necessarily need to test this here, since (hopefully) envToBool already covers this. The test obviously doesn't hurt but wdyt about converting it to it.each if we keep it? This would make it clear which case fails which we don't see with the current implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, I removed the ones that basically just test envToBool but kept some of the other ones. I kept them as is, not via test.each because it seemed harder to follow when I tried that.

@andreiborza andreiborza force-pushed the ab/use-layer-extension-env-variable branch from b9bf109 to f72dc76 Compare November 5, 2025 19:28
Copy link
Member Author

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

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

I reworked the logic a bit to make sure the tunnel is only set when it's feasible (i.e. aws layer + no prior tunnel + no proxy) and cleaned up the warnings around this a bit.

@andreiborza andreiborza requested a review from Lms24 November 5, 2025 19:33
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 24.64 kB - -
@sentry/browser - with treeshaking flags 23.13 kB - -
@sentry/browser (incl. Tracing) 41.26 kB - -
@sentry/browser (incl. Tracing, Profiling) 45.54 kB - -
@sentry/browser (incl. Tracing, Replay) 79.51 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.2 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 84.21 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 96.38 kB - -
@sentry/browser (incl. Feedback) 41.31 kB - -
@sentry/browser (incl. sendFeedback) 29.31 kB - -
@sentry/browser (incl. FeedbackAsync) 34.24 kB - -
@sentry/react 26.32 kB - -
@sentry/react (incl. Tracing) 43.24 kB - -
@sentry/vue 29.13 kB -0.01% -1 B 🔽
@sentry/vue (incl. Tracing) 43.05 kB - -
@sentry/svelte 24.65 kB - -
CDN Bundle 26.9 kB - -
CDN Bundle (incl. Tracing) 41.8 kB - -
CDN Bundle (incl. Tracing, Replay) 78.07 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 83.56 kB - -
CDN Bundle - uncompressed 78.89 kB - -
CDN Bundle (incl. Tracing) - uncompressed 124.01 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 239.2 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 251.96 kB - -
@sentry/nextjs (client) 45.36 kB - -
@sentry/sveltekit (client) 41.67 kB - -
@sentry/node-core 50.81 kB - -
@sentry/node 157.88 kB - -
@sentry/node - without tracing 92.69 kB +0.01% +1 B 🔺
@sentry/aws-serverless 106.46 kB +0.04% +39 B 🔺

View base workflow run

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 this pull request may close these issues.

3 participants