Skip to content

Keep the HTTP/2 receive window credit in sync when the window shrinks - #507

Merged
ericmj merged 1 commit into
mainfrom
apply-http2-client-settings
Sep 24, 2026
Merged

ericmj merged 1 commit into
mainfrom
apply-http2-client-settings

Conversation

@ericmj

@ericmj ericmj commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

Shrinking :initial_window_size adjusted each stream's receive_window_size but not receive_window_remaining, which tracks the server's view of the credit. RFC 9113 6.9.2 has the receiver adjust the windows it maintains "by the difference between the new value and the old value", so the two numbers drifted and the next refill computed receive_window_size - receive_window_remaining as zero or negative.

A negative increment lands in the unsigned 31-bit field as a huge one: connecting with client_settings: [initial_window_size: 200], shrinking to 100 and then receiving one byte of DATA made the client send WINDOW_UPDATE(stream_id: 3, window_size_increment: 2147483549). RFC 9113 6.9.1 requires the server to answer that with a FLOW_CONTROL_ERROR stream reset, and a zero increment is a PROTOCOL_ERROR stream error under 6.9. The remaining credit now follows the size change, and a refill is only sent when the increment is positive.

The :header_table_size half of this change moved to #508, where it lands together with the HPAX.protocol_resize/2 call it needs to be correct. So put_settings(conn, header_table_size: n) still raises a RuntimeError out of stream/2 when the server acknowledges it, until that one merges.

@coveralls

coveralls commented Sep 20, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 48

Coverage increased (+0.007%) to 88.634%

Details

  • Coverage increased (+0.007%) from the base build.
  • Patch coverage: 6 of 6 lines across 1 file are fully covered (100%).
  • 4 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

4 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
lib/mint/http2.ex 4 93.95%

Coverage Stats

Coverage Status
Relevant Lines: 1742
Covered Lines: 1544
Line Coverage: 88.63%
Coverage Strength: 555.3 hits per line

馃挍 - Coveralls

Shrinking :initial_window_size adjusted each stream's receive window
size but not its remaining credit. The server applies the difference to
its view of the window as well (RFC 9113 6.9.2), so the next refill
computed an increment of zero or a negative number and sent it in a
WINDOW_UPDATE frame. A negative increment lands in the unsigned 31-bit
field as a value near 2^31, which the server has to answer with a
FLOW_CONTROL_ERROR stream reset (RFC 9113 6.9.1), and a zero increment
is a PROTOCOL_ERROR stream error (RFC 9113 6.9).

The remaining credit now follows the size change, and a refill is only
sent when the increment is positive.
@ericmj
ericmj force-pushed the apply-http2-client-settings branch from 6184a56 to 48a0066 Compare September 21, 2026 11:02
@ericmj ericmj changed the title Apply acknowledged HTTP/2 client settings for the header table and window sizes Keep the HTTP/2 receive window credit in sync when the window shrinks Sep 21, 2026
@ericmj
ericmj merged commit 369c8af into main Sep 24, 2026
3 checks passed
@ericmj
ericmj deleted the apply-http2-client-settings branch September 24, 2026 09:36
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