-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
HttpConnection leaks UnobservedTaskExceptions #61256
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsIf the Impact: Noise I am able to reproduce the same thing on 5.0 as well. The code is pretty much the same on 3.1, so I assume it would repro there as well (haven't tried since I am relying on the
|
Triage: Might be fixed by #60729 |
Why not backport this one? It'll end up in people's logs (they're logging unobserved tasks). |
I think we should fix this in 8.0. Leaking internal exceptions like this is ugly. |
I observe a lot of these via System.IO.IOException: Unable to read data from the transport connection: Operation canceled.
---> System.Net.Sockets.SocketException (125): Operation canceled
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
at System.Net.Http.HttpConnection.<CheckUsabilityOnScavenge>g__ReadAheadWithZeroByteReadAsync|44_0() I discovered that these are related to pooling. I can significantly reduce these by setting the var handler = new SocketsHttpHandler
{
PooledConnectionIdleTimeout = TimeSpan.FromHours(1),
PooledConnectionLifetime = TimeSpan.FromHours(1),
}; Issue is that I cannot control all created HttpClients. |
If the
SocketsHttpHandler
is not disposed,HttpConnection.Dispose
will not be called in time to observe the exception from thereadAheadTask
. TheDispose
will run as part of the finalizer, but since theTaskExceptionHolder
in_readAheadTask
is also finalizable, it may be too late as the execution order of finalizers is not guaranteed.Impact: Noise
The exceptions that leak to
UnobservedTaskExceptions
would be ignored anyway, so there is no adverse side effects aside from noise.I am able to reproduce the same thing on 5.0 as well. The code is pretty much the same on 3.1, so I assume it would repro there as well (haven't tried since I am relying on the
ConnectCallback
).Example stack trace:
The text was updated successfully, but these errors were encountered: