Skip to content

fix(aws-lambda): Load handler module only once in the layer - #8123

Open
ansh-rohilla wants to merge 1 commit into
getsentry:masterfrom
ansh-rohilla:fix/aws-lambda-load-handler-once-8079
Open

ansh-rohilla wants to merge 1 commit into
getsentry:masterfrom
ansh-rohilla:fix/aws-lambda-load-handler-once-8079

Conversation

@ansh-rohilla

Copy link
Copy Markdown

Description

In sentry_lambda_layer (scripts/init_serverless_sdk.py), sentry_lambda_handler was constructing a new AWSLambdaModuleLoader on every invocation. This caused extract_and_load_lambda_function_module to run repeatedly, re-importing or re-executing the module on every warm invocation.

This change caches the resolved AWSLambdaModuleLoader and entry point handler at module scope upon first invocation so subsequent invocations reuse the cached handler directly. Added unit tests covering cached handler reuse across multiple invocations, handler execution, and loader reset.

Issues

…y#8079)

Cache the resolved AWSLambdaModuleLoader and entry point handler at module scope in init_serverless_sdk so subsequent Lambda invocations reuse the cached handler without re-importing or re-executing the module on each invocation.

Closes getsentry#8079
@ansh-rohilla
ansh-rohilla requested a review from a team as a code owner October 26, 2026 17:28

This branch has not been deployed

No deployments
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.

fix(aws-lambda): Load handler module only once in the layer

1 participant