Don't wait for control stream before processing requests#65399
Don't wait for control stream before processing requests#65399BrennanConroy merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Kestrel's HTTP/3 implementation to start processing incoming requests immediately without waiting for the outbound control stream to be created and SETTINGS to be sent. This change aligns with RFC 9114 section 7.2.4.2, which implies that requests can be processed before the SETTINGS frame is received, and matches HttpClient's existing behavior.
Changes:
- Move outbound control stream creation to a background task that runs concurrently with request processing
- Add comprehensive test coverage for scenarios where the control stream is blocked or never accepted by the client
- Add error handling for control stream failures during cleanup to prevent hangs during graceful shutdown
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Servers/Kestrel/Core/src/Internal/Http3/Http3Connection.cs | Changed control stream initialization to run asynchronously in background without blocking request processing; moved error handling to cleanup phase |
| src/Servers/Kestrel/test/InMemory.FunctionalTests/Http3/Http3ConnectionTests.cs | Added three unit tests covering blocked control stream scenarios: request processing, graceful shutdown, and abort |
| src/Servers/Kestrel/test/Interop.FunctionalTests/Http3/Http3RequestTests.cs | Added two functional tests using real QUIC connections to verify graceful shutdown works when client never accepts server's control stream |
| src/Servers/Kestrel/test/Interop.FunctionalTests/Interop.FunctionalTests.csproj | Added reference to VariableLengthIntegerHelper for HTTP/3 frame encoding in tests |
| return new Http3ControlStream<TContext>(application, httpConnectionContext, 0L); | ||
| OutboundControlStream = new Http3ControlStream<TContext>(application, httpConnectionContext, 0L); | ||
|
|
||
| // Don't delay on waiting to send outbound control stream settings. |
There was a problem hiding this comment.
irrelevant comment? Was it "dont delay" because it was not an awaited task?
There was a problem hiding this comment.
Yeah, should probably remove this and add a comment where we call CreateNewUnidirectionalStreamAsync
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
HTTP/3 RFC implies requests can be processed before the SETTINGS frame is processed.
https://datatracker.ietf.org/doc/html/rfc9114#section-7.2.4.2
HttpClient is also already sending SETTINGS in a background task while starting the rest of it's processing: https://source.dot.net/#System.Net.Http/System/Net/Http/SocketsHttpHandler/[Http3Connection.cs](https://source.dot.net/#System.Net.Http/System/Net/Http/SocketsHttpHandler/Http3Connection.cs,103),103
This PR updates Kestrel to start the control stream and SETTINGS sending in a background thread and start processing incoming requests immediately.