Skip to content

fix: flush queued streams before PING ACK after peer GOAWAY - #1017

Open
magnet wants to merge 2 commits into
hyperium:masterfrom
magnet:flush-before-shutdown-ping-ack
Open

magnet wants to merge 2 commits into
hyperium:masterfrom
magnet:flush-before-shutdown-ping-ack

Conversation

@magnet

@magnet magnet commented Nov 28, 2026 •

Copy link
Copy Markdown

When a server starts the two-step graceful shutdown from RFC 9113 section 6.8, it sends GOAWAY(2^31-1) then a PING, and picks the final last_stream_id once the PING ACK comes back. If the client had already queued a request with send_request() before it read those frames, poll_ready() writes the PING ACK before poll_complete() flushes the queued HEADERS. The server then sees the ACK first, sets a last_stream_id below the new stream, and refuses a request that was sent before the shutdown was seen.

The first commit adds queued_request_flushes_before_shutdown_ping_ack, which fails on master: the mock server receives the PING ACK where it expects HEADERS for stream 1. The second commit flushes queued streams before the pending pong, only when a GOAWAY from the peer has been received. Without a GOAWAY, PING ACKs keep their usual priority.

When a peer initiates an RFC 9113 §6.8 two-step graceful shutdown by
sending GOAWAY(2^31-1) followed by a PING, poll2() previously buffered
the PING ACK via poll_ready() before poll() called streams.poll_complete().
Any request already accepted by send_request() and waiting in the send
buffer could therefore be written after the PING ACK, causing the server
to commit a lower last_stream_id and refuse the in-flight stream.

Flush streams.poll_complete() before send_pending_pong() when a peer
GOAWAY has been received and a pong is pending, while preserving normal
PING ACK priority when no GOAWAY has been received.
@magnet
magnet marked this pull request as ready for review November 28, 2026 13:35

This branch has not been deployed

No deployments
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