Skip to content

fix(stream): avoid RST before initial HEADERS on idle streams#875

Merged
seanmonstar merged 1 commit intohyperium:masterfrom
DDtKey:fix/streams/rst-before-headers
Feb 2, 2026
Merged

fix(stream): avoid RST before initial HEADERS on idle streams#875
seanmonstar merged 1 commit intohyperium:masterfrom
DDtKey:fix/streams/rst-before-headers

Conversation

@DDtKey
Copy link
Contributor

@DDtKey DDtKey commented Jan 30, 2026

Description

If a request body errored before the opening HEADERS were flushed, h2 clears the pending frames and send RST_STREAM first. That leads to a reset on an idle stream, which HTTP/2 forbids, leading peers to reply with PROTOCOL_ERROR/GOAWAY.

But, more importantly, that PROTOCOL_ERROR response 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

Receiving any frame other than HEADERS or PRIORITY on a stream in this state MUST be treated as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

RST_STREAM frames MUST NOT be sent for a stream in the "idle" state.
If a RST_STREAM frame identifying an idle stream is received, the recipient MUST treat this as a connection error (Section 5.4.1) of type PROTOCOL_ERROR.

After fix

When the stream is still pending open, h2 now keeps the queued HEADERS and enqueues the RST_STREAM after them.
This prevents idle-stream resets and keeps behavior within the spec. Already-open streams keep the previous reset behavior.

@DDtKey
Copy link
Contributor Author

DDtKey commented Jan 30, 2026

@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.

Copy link
Member

@seanmonstar seanmonstar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix, thanks so much!

@seanmonstar seanmonstar merged commit 5634ddd into hyperium:master Feb 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants