fix(stream): avoid RST before initial HEADERS on idle streams#875
Merged
seanmonstar merged 1 commit intohyperium:masterfrom Feb 2, 2026
Merged
Conversation
Contributor
Author
|
@seanmonstar may I kindly ask you to review? Tbh, tracking this issue wasn’t easy, but it’s definitely possible to encounter in specific setups where Body streams may experience rapid errors. |
0x676e67
approved these changes
Jan 31, 2026
seanmonstar
approved these changes
Feb 2, 2026
Member
seanmonstar
left a comment
There was a problem hiding this comment.
Great fix, thanks so much!
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
If a request body errored before the opening
HEADERSwere flushed,h2clears the pending frames and sendRST_STREAMfirst. That leads to a reset on an idle stream, which HTTP/2 forbids, leading peers to reply withPROTOCOL_ERROR/GOAWAY.But, more importantly, that
PROTOCOL_ERRORresponse closes the TCP connection (as a connection error per RFC 7540 5.4.1), disrupting other in‑flight streams and potentially leading to a reconnect loop.Expectations
HEADERS/PRIORITYare valid on idle streams.https://datatracker.ietf.org/doc/html/rfc7540#section-5.1
RST_STREAMframes MUST NOT be sent for a stream in the ‘idle’ state…PROTOCOL_ERROR.”https://datatracker.ietf.org/doc/html/rfc7540#section-6.4
After fix
When the stream is still pending open,
h2now keeps the queuedHEADERSand enqueues theRST_STREAMafter them.This prevents idle-stream resets and keeps behavior within the spec. Already-open streams keep the previous reset behavior.