Repository navigation
fix(aws-lambda): Load path-style handlers once per invocation - #8134
Open
pabloDeputter wants to merge 3 commits into
Open
pabloDeputter wants to merge 3 commits into
pabloDeputter wants to merge 3 commits into
Conversation
pabloDeputter
force-pushed
the
pablo/aws-lambda-load-handler-once
branch
from
October 27, 2026 13:27
ca3a347 to
fac06dc
Compare
pabloDeputter
marked this pull request as ready for review
October 27, 2026 13:31
Contributor
Coverage Results 📊✅ 136571 passed | ⏭️ 7334 skipped | Total: 143905 | Pass Rate: 94.9% | Execution Time: 446m 32s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 100.00% (no changed executable lines found; target 80%). Coverage diff@@ Coverage Diff @@
## master #8134 +/-##
==========================================
+ Coverage 90.27% 90.30% +0.03%
==========================================
Files 203 203 —
Tracked lines 26880 26880 —
Branches 10042 10042 —
==========================================
+ Hits 24266 24273 +7
+ Misses 2614 2607 -7
Partials 1520 1520 —Generated by Coverage Action |
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
Path-style handlers, e.g.
SENTRY_INITIAL_HANDLER=app/index.handler, were manually loaded and never cached unlike dotted handlers, e.g.index.handlerwhich automatically ended up insys.modules; so module was loaded again on every warm invocation and state was lost.Changes & Results
Loader now does the same as Lambda runtime itself:
/is turned into.andimportlib.import(...)is called; Python caches the module, so it runs exactly once per execution environment.Some results below on a Lambda function (python3.13, arm64, 512 MB) that creates 3 boto3 clients at import:
Warm invocations: p50 122ms => 58ms; p99 180ms => 69ms.
Cold starts remain the same, 1.4s for both.
Peak memory also drops from 117 MB => 108 MB and is fixed on invocations, unlike the old layer which grows over time because each call creates new clients.
Issues
Resolves #8079 & PY-3016