Conversation
Add try-catch block around ReadAsync in ProcessServerStreamAsync to handle QuicException with StreamAborted error when reading multi-byte stream type headers with tracing enabled. This ensures compliance with RFC 9114 which requires tolerating stream resets prior to receiving the complete unidirectional stream header. Co-authored-by: MihaZupan <[email protected]>
Copilot
AI
changed the title
[WIP] Fix handling of unidirectional server-initiated streams in Http3Connection
Fix unhandled QuicException when server resets unidirectional stream during tracing
Dec 15, 2025
MihaZupan
approved these changes
Dec 15, 2025
Member
MihaZupan
left a comment
There was a problem hiding this comment.
I'd also be fine with deleting this whole if (NetEventSource.Log.IsEnabled()) block if we don't see the value in this particular message.
rzikm
reviewed
Dec 16, 2025
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: CarnaViire <[email protected]>
Co-authored-by: CarnaViire <[email protected]>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Copilot
AI
changed the title
Fix unhandled QuicException when server resets unidirectional stream during tracing
Refactor HTTP/3 server stream handling to consolidate exception handling for stream resets
Dec 17, 2025
rzikm
reviewed
Dec 17, 2025
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Outdated
Show resolved
Hide resolved
MihaZupan
reviewed
Dec 18, 2025
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Outdated
Show resolved
Hide resolved
MihaZupan
reviewed
Dec 18, 2025
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Outdated
Show resolved
Hide resolved
…h statement Co-authored-by: MihaZupan <[email protected]>
rzikm
approved these changes
Dec 18, 2025
MihaZupan
reviewed
Dec 18, 2025
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: MihaZupan <[email protected]>
MihaZupan
approved these changes
Dec 18, 2025
This was referenced Jan 9, 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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description
When NetEventSource tracing is enabled, the HTTP/3 client throws an unhandled
QuicExceptionif the server resets a unidirectional stream while the client reads a multi-byte stream type header. This violates RFC 9114, which requires tolerating stream resets before receiving the complete stream header.Refactored the stream type reading logic to consolidate exception handling in a single location before the switch statement:
QuicExceptionwithQuicError.StreamAbortedthat covers all reads needed to parse the stream type, not just the diagnostic logging pathswitch ((Http3StreamType)streamType)with clean enum case labels instead of casting each casebytesReadvariable into loop scope for better code qualityThe refactoring consolidates the exception handling pattern that existed at line 598 to cover all stream type reads, removing 32 lines of duplicate code while ensuring RFC 9114 compliance.
Customer Impact
With tracing enabled, server-side stream resets (legitimate per RFC 9114) cause the entire HTTP/3 connection to abort with
HttpProtocolException, breaking all in-flight requests. Without this fix, enabling diagnostics paradoxically makes the client less robust.Regression
No. This is a pre-existing bug exposed only when NetEventSource tracing is enabled and the server sends a stream type ≥ 0x40 (requiring 2+ bytes) then resets before sending all bytes.
Testing
Risk
Low. Refactoring moves existing exception handling logic to cover all stream type reads instead of only the first byte. Bidirectional stream check remains at original efficient position. Variable scoping changes are purely code quality improvements with no functional impact. No behavior change when streams complete normally. Actually reduces risk by eliminating code duplication and making the exception handling more comprehensive.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.