-
Notifications
You must be signed in to change notification settings - Fork 360
fix: use WeakRef for storing req and res for AppSec #7276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7276 +/- ##
==========================================
- Coverage 85.14% 77.13% -8.02%
==========================================
Files 532 526 -6
Lines 22897 22733 -164
==========================================
- Hits 19495 17534 -1961
- Misses 3402 5199 +1797 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overall package sizeSelf size: 4.41 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.0 | 68.46 kB | 797.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
|
This fixes a memory leak by making sure the exposed req and res of http are not hold onto strongly. It does that by skipping adding these to the store, if not needed as well as creating a WeakRef when it is needed. That way AppSec still has access to these as long as the request is alive. Router now also uses a WeakMap for the context to prevent any hard references and the parent store in http server is refactored next to using private properties and adding some types. Fixes: #6389
ac69075 to
8ae52ce
Compare
BenchmarksBenchmark execution time: 2026-01-20 00:18:25 Comparing candidate commit 8ae52ce in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 233 metrics, 27 unstable metrics. |
This fixes a memory leak by making sure the exposed req and res of
http are not hold onto strongly.
It does that by skipping adding these to the store, if not needed
as well as creating a WeakRef when it is needed. That way AppSec
still has access to these as long as the request is alive.
Router now also uses a WeakMap for the context to prevent any hard
references and the parent store in http server is refactored next
to using private properties and adding some types.
Fixes: #6389