Skip to content

http3: fix race between new streams and GOAWAY#5522

Merged
marten-seemann merged 3 commits intomasterfrom
http3-fix-client-goaway-race
Jan 3, 2026
Merged

http3: fix race between new streams and GOAWAY#5522
marten-seemann merged 3 commits intomasterfrom
http3-fix-client-goaway-race

Conversation

@marten-seemann
Copy link
Copy Markdown
Member

@marten-seemann marten-seemann commented Jan 3, 2026

Fix race in http3 client by canceling newly opened streams on GOAWAY and making ClientConn.openRequestStream respect maxStreamID with monotonic lastStreamID tracking

Update ClientConn.openRequestStream to re-check maxStreamID after opening and cancel streams with H3_REQUEST_CANCELED when StreamID >= maxStreamID; make lastStreamID updates monotonic under concurrency; document maxStreamID/lastStreamID semantics in ClientConn; add a concurrency test and consolidate test connection helpers in http3/http3_helper_test.go.

📍Where to Start

Start with ClientConn.openRequestStream in http3/client.go, then review the new concurrency test TestClientConnGoConcurrent in http3/client_test.go.


Macroscope summarized 682071a.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.11%. Comparing base (29b1a15) to head (682071a).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5522      +/-   ##
==========================================
+ Coverage   84.05%   84.11%   +0.06%     
==========================================
  Files         159      159              
  Lines       16334    16342       +8     
==========================================
+ Hits        13729    13746      +17     
+ Misses       1973     1966       -7     
+ Partials      632      630       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a race condition between opening new streams and receiving GOAWAY frames in HTTP/3 client connections. The fix ensures that streams opened concurrently are properly tracked and rejected if they exceed the GOAWAY limit.

Key changes:

  • Refactored test helper functions to use an options pattern for better flexibility
  • Added double-check logic in openRequestStream to handle concurrent stream opening and GOAWAY reception
  • Added comprehensive test coverage for the concurrent GOAWAY scenario

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
http3/client.go Fixed race condition by adding double-check pattern after stream opening to verify against GOAWAY limit, with improved comments
http3/http3_helper_test.go Refactored connection pair creation from separate functions to unified newConnPair with options pattern for better flexibility
http3/client_test.go Updated to use new test helper API and added TestClientConnGoConcurrent to verify concurrent stream opening with GOAWAY
http3/server_test.go Updated test calls to use new withServerRecorder option
http3/stream_test.go Updated test calls to use new withClientRecorder option
http3/frames_test.go Updated test calls to use new withDatagrams and withServerRecorder options
http3/conn_test.go Updated test calls to use new options-based test helper API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread http3/client_test.go
Comment thread http3/client.go Outdated
Comment thread http3/client_test.go
Comment thread http3/client_test.go Outdated
Comment thread http3/client_test.go
marten-seemann and others added 2 commits January 3, 2026 13:57
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@marten-seemann marten-seemann merged commit e8a6e37 into master Jan 3, 2026
49 checks passed
@marten-seemann marten-seemann deleted the http3-fix-client-goaway-race branch January 11, 2026 02:40
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.

http3: race condition in stream ID check during graceful shutdown

2 participants