fix(h2): release completed requests from queue#5569
Merged
Conversation
The HTTP/2 in-order completion fast path advanced the running index but retained the completed Request in its queue slot until batched compaction. Under sustained abort churn, each retained Request pinned its stream and fetch graph, including native response buffers. Clear the completed slot before advancing, preserving the O(1) fast path, and finalize closed streams even when the Request was already marked aborted. Fixes: nodejs#5566 Signed-off-by: Scott Taylor <scott.c.taylor@mac.com> Assisted-By: devx/4ad398e1-8641-4e85-a62d-cb78992a7aae
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5569 +/- ##
=======================================
Coverage 93.47% 93.47%
=======================================
Files 110 110
Lines 37507 37561 +54
=======================================
+ Hits 35059 35111 +52
- Misses 2448 2450 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
I'm relatively concerned by this PR (and previous ones) that do not actually provide e2e tests. |
Signed-off-by: Scott Taylor <scott.c.taylor@mac.com> Assisted-By: devx/7d65db46-a09e-471a-9e1c-abdaa5accba8
Contributor
Author
|
Thanks @mcollina — agreed. I’ve added an end-to-end regression test in 84ab33d. It uses a real TLS HTTP/2 server through the public |
Co-authored-by: Carlos Fuentes <me@metcoder.dev>
Signed-off-by: Matteo Collina <hello@matteocollina.com>
Merged
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.
This relates to...
Fixes #5566.
Rationale
The HTTP/2 in-order completion optimization introduced in #5483 advanced
kRunningIdxwithout clearing the completed request's queue slot. Until the periodic queue compaction ran, each dead prefix slot retained itsRequest, whose controller retained theClientHttp2Streamand the rest of the fetch graph. Under sustained HTTP/2 abort churn this retained native response buffers and caused memory growth. A 20,000-request reproduction at 50% aborts grew the heap by 10.6 MB before this change and 2.8 MB after it, matching the pre-#5483 baseline.A stream can also close after its request has already been marked aborted. Terminal stream cleanup must still finalize that request even though
onResponseEndmust not run.Changes
Features
N/A
Bug Fixes
kRunningIdx, preserving the O(1) fast path and matching the existing HTTP/1 queue behavior.Breaking Changes and Deprecations
N/A
Status