Fix H2 window flow control bugs causing flaky CI timeouts#582
Merged
Conversation
- Use negotiated SETTINGS_INITIAL_WINDOW_SIZE for new streams instead of hardcoded 65535 (OverallWindowSize). Streams created after the SETTINGS exchange were missing the server's initial window, causing the client to block on an exhausted stream window while the server believed it had plenty — root cause of 30s timeouts on large request bodies. - Set Remote PeerSetting.WindowSize default to 65535 (RFC 9113 §6.5.2). - Fix _initDone = false (should be true) in H2ConnectionPool.Init(), which allowed double-initialization of the connection. - Fix lost-wakeup race in WindowSizeHolder: wake a waiter whenever the window is positive, not only on the ≤0 → >0 transition. Concurrent UpdateWindowSize calls could silently skip the wake. - Make StreamPool.ShouldWindowUpdate thread-safe with Interlocked ops. - Add larger payload (150002 * 16) to Http2ClientHandler test coverage.
This was referenced Mar 30, 2026
This was referenced Apr 13, 2026
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.
Summary
OverallWindowSize(65535) instead of the server's negotiated initial window size. When the server advertises a larger window (e.g. 1MB), the client exhausts 65535 bytes then blocks waiting for a stream-level WINDOW_UPDATE that the server never sends (it believes the stream still has plenty of window). This is the root cause of 30s timeouts on large request bodies (e.g.Check_Global_Healthwith 150KB)._initDoneguard fixed:Init()set_initDone = falseinstead oftrue, allowing double-initialization of the connection (duplicate preface + read/write loops).UpdateWindowSizecalls raced, only the one crossing the 0-to-positive boundary would wake a waiter. The other's increment was silently added without waking anyone, starving blocked streams.+=withInterlocked.AddandInterlocked.Exchange.Http2ClientHandler.GetHttpMethods.