You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected exception type in Http3RequestStream.SendAsync: System.Net.Quic.QuicException: Operation aborted. #111507
Known Build ErrorUse this to report build issues in the .NET Helix tabarea-System.Net.Quicblocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'in-prThere is an active PR which will close this issue when it is merged
Notice that the stream opening is not in lock (it's async). So we take the connection, open the stream and now switch back to the GO_AWAY and InvalidateHttp3Connection.
So the GO_AWAY thread is invalidating the connection on which we've opened the stream (stream id 8), but not yet added it into _activeRequests. So we set dispose the connection:
And we end up closing the connection from our side ==> which is the source of System.Net.Quic.QuicException: Operation aborted (locally closed connection).
And now back to the retry, we add the request into _activeRequests and continue in SendAsync, we also evaluate goAway as not-applicable since our stream id 8 is smaller than long.MaxValue:
And the first operation on the stream blows up with QuicException(OperationAborted) which we can see in the console log:
Process terminated. Assertion failed.
Unexpected exception type in Http3RequestStream.SendAsync: System.Net.Quic.QuicException: Operation aborted.
at System.Net.Quic.ResettableValueTaskSource.TryComplete(Exception exception, Boolean final) in /_/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/ResettableValueTaskSource.cs:line 177
at System.Net.Quic.ResettableValueTaskSource.TrySetException(Exception exception, Boolean final) in /_/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/ResettableValueTaskSource.cs:line 237
at System.Net.Quic.QuicStream.HandleEventShutdownComplete(_SHUTDOWN_COMPLETE_e__Struct& data) in /_/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs:line 642
at System.Net.Quic.QuicStream.HandleStreamEvent(QUIC_STREAM_EVENT& streamEvent) in /_/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs:line 665
at System.Net.Quic.QuicStream.NativeCallback(QUIC_HANDLE* stream, Void* context, QUIC_STREAM_EVENT* streamEvent) in /_/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs:line 694
--- End of stack trace from previous location ---
at System.Net.Quic.ResettableValueTaskSource.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) in /_/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/ResettableValueTaskSource.cs:line 251
at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken) in /_/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs:line 172
at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken) in /_/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs:line 172
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine) in /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilderCore.cs:line 38
at System.Net.Http.Http3RequestStream.SendAsync(CancellationToken cancellationToken)
at System.Net.Http.Http3Connection.SendAsync(HttpRequestMessage request, Int64 queueStartingTimestamp, Activity waitForConnectionActivity, CancellationToken cancellationToken) in /_/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs:line 318
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs:line 179
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread) in /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs:line 356
at System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(IAsyncStateMachineBox box, Boolean allowInlining) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs:line 795
at System.Threading.Tasks.Task.RunContinuations(Object continuationObject) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs:line 3478
at System.Runtime.CompilerServices.AsyncValueTaskMethodBuilder`1.SetResult(TResult result) in /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncValueTaskMethodBuilderT.cs:line 47
at System.Net.Quic.QuicConnection.OpenOutboundStreamAsync(QuicStreamType type, CancellationToken cancellationToken) in /_/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicConnection.cs:line 558
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) in /_/src/libraries/System.Private.CoreLib/src/System/Threading/ExecutionContext.cs:line 264
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread) in /_/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncTaskMethodBuilderT.cs:line 356
at System.Threading.ThreadPoolWorkQueue.Dispatch() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs:line 1118
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/PortableThreadPool.WorkerThread.cs:line 127
at System.Threading.Thread.StartHelper.RunWorker() in /_/src/libraries/System.Private.CoreLib/src/System/Threading/Thread.cs:line 77
The console log leads an assert in Http3RequestStream.SendAsync:
Debug.Fail($"Unexpected exception type in Http3RequestStream.SendAsync: {ex}");
And going back through all the catch blocks, we expect System.Net.Quic.QuicException: Operation aborted only in case of cancellation or connection abort.
Known Build ErrorUse this to report build issues in the .NET Helix tabarea-System.Net.Quicblocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'in-prThere is an active PR which will close this issue when it is merged
Activity
dotnet-policy-service commentedon Jan 16, 2025
Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.
ManickaP commentedon Jan 17, 2025
It's a race between retrying the rejected request and processing GO_AWAY.
The failing test is
SendAsync_RequestRejected_ClientRetries.Root cause in details:
Details
There's only one client connection and there are actually 3 retries of the same request. The first attempt (stream id 0) gets rejected on:
runtime/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http3.cs
Line 395 in 4de59c4
The second retry (stream id 4) gets rejected via:
runtime/src/libraries/Common/tests/System/Net/Http/Http3LoopbackConnection.cs
Line 312 in 4de59c4
In the meantime, there's GO_AWAY with stream id 0 on the way to the client.
Client receives GO_AWAY and first thing it does (outside of lock, before setting
_firstRejectedStreamId) isInvalidateHttp3Connection(this is happening on a separate thread stemming from control stream processing): https://github.com/dotnet/runtime/blob/4de59c4db6a2357532865d1805ee8b517ca4ab60/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs#L400C19-L400C44Now we have to switch contexts back to the request retry, the H3Connection is still not removed from the pool ==> for the third time, we attempt to send the request on it:
runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Lines 258 to 272 in 4de59c4
Notice that the stream opening is not in lock (it's async). So we take the connection, open the stream and now switch back to the GO_AWAY and
InvalidateHttp3Connection.So the GO_AWAY thread is invalidating the connection on which we've opened the stream (stream id 8), but not yet added it into
_activeRequests. So we set dispose the connection:runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Lines 112 to 122 in 4de59c4
Setting
_firstRejectedStreamIdtolong.MaxValueand and invokingCheckForShutdown(note that_activeRequestsis still empty):runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Line 145 in 4de59c4
And we end up closing the connection from our side ==> which is the source of
System.Net.Quic.QuicException: Operation aborted(locally closed connection).And now back to the retry, we add the request into
_activeRequestsand continue inSendAsync, we also evaluategoAwayas not-applicable since our stream id 8 is smaller thanlong.MaxValue:runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Lines 307 to 311 in 4de59c4
And we end up sending the request:
runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs
Line 322 in 4de59c4
But the connection is closed, the stream received SHUTDOWN_COMPLETE:
runtime/src/libraries/System.Net.Quic/src/System/Net/Quic/QuicStream.cs
Lines 634 to 635 in 4de59c4
And the first operation on the stream blows up with
QuicException(OperationAborted)which we can see in the console log:The console log leads an assert in
Http3RequestStream.SendAsync:runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3RequestStream.cs
Line 357 in 4de59c4
And going back through all the catch blocks, we expect
System.Net.Quic.QuicException: Operation abortedonly in case of cancellation or connection abort.