Repository navigation
Conversation
|
Checked the behaviour rather than only the added test, and it matches what the description and CHANGELOG claim. RFC 9113 does not contradict it, which I also wanted to confirm before spending more time here. The RFC anchor holds. There is no connection state machine section in RFC 9113 — §5.1 is stream states only — so the relevant text is §5.4.2, which says that after RST_STREAM "the peer ... MUST be prepared to receive any frames that were sent or enqueued for sending by the remote peer. These frames can be ignored, except where they modify connection state". §6.8 only forbids opening new streams after GOAWAY; it does not require a connection error for frames still in flight. So dropping them is defensible, and §5.4.2 is the precedent for it. All nine frame types, not just the one in the test. I drove a server connection into So the guard does cover the whole dispatch table, not just the leftovers the test happens to use. Two specifics worth stating because they are easy to get wrong: a PING in this state gets no ACK, which matches the description, and a further GOAWAY is still processed rather than dropped, which is what keeps the existing multi-GOAWAY tests valid. Calling Suite and coverage. One note on my own tooling rather than the PR: my first two attempts at this matrix produced two false positives — a GOAWAY with a zero length field, and a |
|
@adarshx01, thank you for the leftover-frame handling. #1346 includes your commit unchanged, with your authorship, and builds receive-side draining on it. I offer this as a consolidation, subject to your preference. If you prefer separate PRs, I can rebase after yours merges. Subsequent changes adapt both the ignore guard and its test. The guard excludes draining connections, and the test uses an error GOAWAY. During a graceful drain, h2 processes open streams and acknowledges PING. After terminal closure, your leftover-frame handling applies. The companion change is mitmproxy/mitmproxy#8580. |
RFC 9113, Section 6.8 lets streams at or below a GOAWAY's last stream ID complete. Servers often shut down in two stages: GOAWAY(NO_ERROR) with a high last stream ID, a PING, then a GOAWAY with the real last stream ID. h2 moved to CLOSED on any GOAWAY, so the PING or the rest of an open response raised "Invalid input ... in state ConnectionState.CLOSED". After a GOAWAY with NO_ERROR, the connection now drains: - The state stays CLOSED, so consumers that check for CLOSED still stop opening streams on the connection. H2ConnectionStateMachine.draining reports the drain. - Frames for open streams are still processed. PING and SETTINGS are still acknowledged. PUSH_PROMISE can still be received. The outbound buffer is kept. - The drain keeps a shadow of the open state, so the client and server rules of the open connection still apply. - New local streams (send_headers on a new stream ID, push_stream, initiate_upgrade_connection) raise ProtocolError before any state change, and the drain continues. - A further graceful GOAWAY continues the drain. A GOAWAY with an error code, an invalid input or close_connection() ends it. A graceful GOAWAY never reopens a connection that is already closed. ConnectionTerminated is still fired for every GOAWAY. h2 does not reset or filter streams above last_stream_id; the application decides. Fixes python-hyper#1199. Fixes the receive side of python-hyper#1181. Builds on python-hyper#1324. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Fixes #1199.
After GOAWAY (or any other path into CLOSED), the TCP receive buffer can still hold PING/DATA/SETTINGS frames. Those currently miss the CLOSED transition table and raise
ProtocolError. Extra GOAWAY frames stay valid, matching the existing multi-GOAWAY tests; everything else is dropped and does not generate a PING ACK.