Skip to content

Fix HTTP/2 send when flow-control window is negative - #1083

Open
mbeijen wants to merge 1 commit into
encode:masterfrom
mbeijen:1082-negative-control-flow-window
Open

Fix HTTP/2 send when flow-control window is negative#1083
mbeijen wants to merge 1 commit into
encode:masterfrom
mbeijen:1082-negative-control-flow-window

Conversation

@mbeijen

@mbeijen mbeijen commented May 12, 2026

Copy link
Copy Markdown

Summary

_wait_for_outgoing_flow previously waited only while the available flow was exactly zero. Per RFC 7540 §6.9.2, when a peer sends a SETTINGS frame that reduces INITIAL_WINDOW_SIZE, every existing stream send window is adjusted by the delta and may become negative. With the while flow == 0 guard, a negative window passed straight through and h2 raised LocalProtocolError("Cannot send N bytes, flow control window is -M") on the next send_data call.

Switching the guard to while flow <= 0 keeps the stream parked until WINDOW_UPDATE frames restore positive credit.

Refs: #1082
Refs: encode/httpx#3601

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.

`_wait_for_outgoing_flow` previously waited only while the available
flow was exactly zero. Per RFC 7540 §6.9.2, when a peer sends a SETTINGS
frame that reduces INITIAL_WINDOW_SIZE, every existing stream send
window is adjusted by the delta and may become negative. With the
`while flow == 0` guard, a negative window passed straight through and
h2 raised `LocalProtocolError("Cannot send N bytes, flow control window
is -M")` on the next send_data call.

Switching the guard to `while flow <= 0` keeps the stream parked until
WINDOW_UPDATE frames restore positive credit.

Refs: encode#1082
Refs: encode/httpx#3601
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

Development

Successfully merging this pull request may close these issues.

1 participant