Repository navigation
fix(mux-h2): keep one stream send window per connection - #1757
Merged
Merged
Conversation
RFC 9113 §6.9 flow control is per hop, but a stream relayed from an H2 frontend to an H2 backend kept one send window for both connections. A client and a backend both advertising SETTINGS_INITIAL_WINDOW_SIZE = 2^31-1 overflowed it and the backend connection was closed with GOAWAY(PROTOCOL_ERROR); the backend leg also started at the frontend's window, and each peer's WINDOW_UPDATE credited the other leg. Split Stream::window into front_window and back_window. Stream::split and the new Stream::send_window_mut select the connection's own leg from its Position, and ConnectionH2::start_stream sizes the backend leg from the backend's initial window. H1 legs are unchanged. Fixes #1755 Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
force-pushed
the
fix/h2-per-leg-stream-window
branch
from
October 1, 2026 20:00
c877920 to
fccc0e3
Compare
Signed-off-by: Florentin Dubois <[email protected]>
a_backend_stream_answered_before_its_request_was_written_is_cancelled, added with #1741, withholds the backend's send window by setting Stream::window to 0. This branch splits that field into front_window and back_window, one per connection (RFC 9113 section 6.9), so after main was merged in the test no longer compiled: the two changes touched different lines and merged without a textual conflict. The test drives the stream on its backend connection, whose send window is now back_window (Stream::send_window_mut picks the leg from the connection's Position). Set that leg to 0 so the request body still waits behind its HEADERS, as the test intends. Signed-off-by: Florentin Dubois <[email protected]>
Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS
added a commit
that referenced
this pull request
Oct 2, 2026
…#1782) With an H1 client in front of an H2 backend, the second request on a keep-alive client connection was answered 502. `ConnectionH1::writable` reused the client stream slot without clearing the end-of-stream flags and DATA counters that `Context::create_stream` clears for a recycled slot. The H2 backend connection then refused the second response's HEADERS as arriving on a closed stream (RFC 9113 §5.1) and sent GOAWAY(STREAM_CLOSED). The keep-alive reset now clears them, and `ConnectionH2::start_stream` asserts (debug builds) that the backend leg is fresh. The backend leg's send window is sized from the backend's SETTINGS_INITIAL_WINDOW_SIZE since #1757: without it, a keep-alive request started from what the previous one left of the window, so large request bodies stalled, and a backend advertising less than 65 535 was over-run. Tests, `e2e/src/tests/tests.rs`: - `test_h1_to_h2_keep_alive_requests` - `test_h1_to_h2_keep_alive_requests_small_backend_window` Each sends a GET, four 600 000-byte POSTs and a GET on one client connection, and asserts one backend connection and six backend requests, with the default and a 16 384-byte backend window. Both fail without #1757: `[true, false, …]` with the small window, `[true, true, true, false, …]` with the default. The H2 mock backend now counts accepted connections and can advertise a stream window. Documented in `lib/src/protocol/mux/LIFECYCLE.md` §3.2 and `CHANGELOG.md`. Fixes #1781 Signed-off-by: Florentin Dubois <[email protected]>
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.
RFC 9113 §6.9 flow control is per connection. A stream relayed from an H2 frontend to an H2 backend kept a single send window for both, so a client and a backend that each advertise
SETTINGS_INITIAL_WINDOW_SIZE = 2^31-1overflowed it (§6.9.2) and the backend connection was closed with GOAWAY(PROTOCOL_ERROR). The backend leg also started at the frontend's window, and each peer's WINDOW_UPDATE credited both legs.Stream::windowbecomesStream::front_windowandStream::back_window.Stream::splitand the newStream::send_window_mutselect the connection's own leg from itsPosition; SETTINGS and WINDOW_UPDATE handling use it.ConnectionH2::start_streamsizes the backend leg from the backend'sSETTINGS_INITIAL_WINDOW_SIZE.Tests: unit
a_backend_max_initial_window_is_independent_of_the_frontend_window,a_backend_stream_window_is_sized_and_credited_by_the_backend_only,a_frontend_window_update_credits_the_frontend_leg_only; e2etest_h2_client_and_h2_backend_both_at_max_initial_window. Docs and CHANGELOG updated.Fixes #1755