Skip to content

Treat DATA on a RST-closed stream as a connection error per RFC 9113 §5.1 - #1129

Open
arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:rfc9113-closed-stream-connection-error
Open

arturobernalg wants to merge 1 commit into
apache:mainfrom
arturobernalg:rfc9113-closed-stream-connection-error

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

RFC 9113, section 5.1 permits an endpoint to treat receipt of any frame other than PRIORITY, WINDOW_UPDATE, or RST_STREAM on a closed stream as a connection error (Section 5.4.1) of type STREAM_CLOSED.

The CLOSED_RST_RX state (stream closed because a RST_STREAM was received from the peer) had connectionErrorForInvalidFrame=false, so any frame not in the permitted set — in particular DATA — triggered a StreamException (stream error) and caused the server to reply with a RST_STREAM instead of closing the connection with GOAWAY.

Fix: set connectionErrorForInvalidFrame=true for CLOSED_RST_RX so that unexpected frames such as DATA trigger a connection error (GOAWAY STREAM_CLOSED). Add RST and WINDOW_UPDATE to the permitted set so they are silently discarded as expected for in-flight frames after a reset.

Update TestHttp2Section_5_1#testClosedInvalidFrame01 to assert the correct connection-error (GOAWAY STREAM_CLOSED) response.

@arturobernalg
arturobernalg force-pushed the rfc9113-closed-stream-connection-error branch from 32ae7a8 to f805a6d Compare October 29, 2026 18:56
@arturobernalg

Copy link
Copy Markdown
Member Author

Review addressed. Tests updated: testClosedInvalidFrame01 now drives stream 3 to CLOSED_TX via a full request/response cycle, then sends RST_STREAM to transition the server to CLOSED_RST_RX before verifying that DATA triggers a connection error. Two new tests added: testRstStreamAfterRstStreamReceived and testWindowUpdateAfterRstStreamReceived confirm the connection stays alive when RST_STREAM or WINDOW_UPDATE is received on a CLOSED_RST_RX stream. All tests pass.

RFC 9113, section 5.1 permits an endpoint to treat receipt of any frame
other than PRIORITY, WINDOW_UPDATE, or RST_STREAM on a closed stream as
a connection error (Section 5.4.1) of type STREAM_CLOSED.

The CLOSED_RST_RX state (stream closed because a RST_STREAM was received
from the peer) had connectionErrorForInvalidFrame=false, so any frame not
in the permitted set — in particular DATA — triggered a StreamException
and caused the server to reply with a RST_STREAM (stream error) instead
of closing the connection with GOAWAY (connection error).

Fix: set connectionErrorForInvalidFrame=true for CLOSED_RST_RX so that
unexpected frames such as DATA trigger a connection error (GOAWAY
STREAM_CLOSED). Add RST and WINDOW_UPDATE to the permitted set so they
are silently discarded as expected for in-flight frames after a reset.

Update TestHttp2Section_5_1#testClosedInvalidFrame01 to assert the
correct connection-error (GOAWAY STREAM_CLOSED) response.
@arturobernalg
arturobernalg force-pushed the rfc9113-closed-stream-connection-error branch from f805a6d to c7a5df7 Compare October 29, 2026 19:20
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.

1 participant