-
Couldn't load subscription status.
- Fork 5.2k
[QUIC] fix unobserved exceptions #104894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[QUIC] fix unobserved exceptions #104894
Conversation
|
Tagging subscribers to this area: @dotnet/ncl |
| } | ||
|
|
||
| internal static bool TryGetStreamExceptionForMsQuicStatus(int status, [NotNullWhen(true)] out Exception? exception, bool streamWasSuccessfullyStarted = true, string? message = null) | ||
| internal static bool TryGetStreamExceptionForMsQuicStatus(int status, [NotNullWhen(true)] out Exception? exception) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the special exception here. MsQuic will throw either ABORTED or INVALID_STATE in case the connection is closed (remotely / locally). It also doesn't use these statuses for anything else.
| } | ||
| } | ||
|
|
||
| public static void ObserveException(this Task task) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follows the same pattern as LogExceptions in HttpConnection.
| /// <summary> | ||
| /// Completed when connection shutdown is initiated. | ||
| /// </summary> | ||
| private readonly TaskCompletionSource _connectionCloseTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moved around to be next to other connection closure fields.
| Debug.Assert(_connectionCloseTcs.Task.IsCompleted); | ||
| _handle.Dispose(); | ||
| _shutdownTokenSource.Dispose(); | ||
| _connectionCloseTcs.Task.ObserveException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the FIX.
I thought the same when I added dumping MsQuic counters for System.Net.Quic tests. But I am not sure we can just go and update xUnit to v3 |
I don't think it's even out yet 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
/azp run runtime-libraries-coreclr outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Addresses the last issue with unobserved exception leaking from
_connectionCloseTcs.Fixes #80111
Testing
I used Miha's trick from #80111 (comment) to manually check for unobserved exceptions from HTTP tests, but we don't have a collection fixture like
QuicTestCollectionto add similar print like:runtime/src/libraries/System.Net.Quic/tests/FunctionalTests/QuicTestCollection.cs
Line 97 in 9d24b13
in HTTP. And adding it and annotating the whole test lib felt like out of the scope for this PR.
Also note that from xUnit 3 there should be
Assembly Fixtureswhich wouldn't require annotating every single test class in an assembly.