Send RST_STREAM for a cancelled half-closed stream - #710
Merged
Merged
Conversation
Member
|
@rp-arielrodriguez RST_STREAM is not subject to flow control. Shouldn't a pending stream reset be processed regardless of connOutputWindow? |
Contributor
Author
|
@arturobernalg Agreed, thanks. I will apply the window check only to normal stream output, so a pending reset is sent even when |
rp-arielrodriguez
force-pushed
the
h2-cancel-rst
branch
2 times, most recently
from
September 29, 2026 20:44
2561359 to
901d28d
Compare
ok2c
reviewed
Sep 30, 2026
A cancelled stream was reset only when a frame arrived from the peer. A stream that had already sent END_STREAM produces no more output, so a silent peer never received RST_STREAM(CANCEL). The multiplexer now resets such a stream on output. RST_STREAM is not subject to flow control, so the reset does not wait for the connection output window. Generated-by: Claude Code (Claude Opus 5.5)
rp-arielrodriguez
force-pushed
the
h2-cancel-rst
branch
from
September 30, 2026 13:32
901d28d to
4795f64
Compare
ok2c
approved these changes
Sep 30, 2026
Member
|
@rp-arielrodriguez Cherry-picked to 5.4.x though I had to port the tests manually. Please double-check. |
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.
We found this with HTTP/2 multiplexing in HttpClient 5: when a GET timed out
on a shared connection and the server stayed silent, no RST_STREAM was sent.
The server kept working on the request, and the stream kept its slot.
H2Stream#abort()setscancelledand callsrequestOutput(), but the flag ischecked only in
consumeHeader,consumeDataandconsumePromise. The outputloop skips local-closed streams, so a half-closed stream with a silent peer is
never reset.
Fix:
H2Stream#resetIfCancelled()sends RST_STREAM(CANCEL) for a cancelledhalf-closed stream.
onOutput()calls it for each stream, outside theconnection window check, because RST_STREAM is not subject to flow control.
Backport: the main code applies cleanly to 5.4.x; the test file needs a small
merge.
Tests:
testAbortAfterLocalEndStreamSendsRstStreamWithoutInboundFrames(failson master, passes with the fix).
testAbortAfterLocalEndStreamSendsRstStreamWithNoConnectionWindow(failson master and on the previous revision of this PR, passes with the fix).
./mvnw -pl httpcore5-testing -am test: httpcore5 1960, httpcore5-h2 388,httpcore5-testing 443 (4 skipped), all pass. Checkstyle and RAT pass.
I used an AI assistant (Claude Code) for this change. I reviewed all of it and
I can answer questions about it.