Repository navigation
fix(aws-lambda): Load handler module only once in the layer - #8123
Open
ansh-rohilla wants to merge 1 commit into
Open
ansh-rohilla wants to merge 1 commit into
ansh-rohilla wants to merge 1 commit into
Conversation
…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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In
sentry_lambda_layer(scripts/init_serverless_sdk.py),sentry_lambda_handlerwas constructing a newAWSLambdaModuleLoaderon every invocation. This causedextract_and_load_lambda_function_moduleto run repeatedly, re-importing or re-executing the module on every warm invocation.This change caches the resolved
AWSLambdaModuleLoaderand 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