-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Avoid UnobservedTaskExceptions from HttpConnection.PrepareForReuse
#104335
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
Avoid UnobservedTaskExceptions from HttpConnection.PrepareForReuse
#104335
Conversation
|
Tagging subscribers to this area: @dotnet/ncl |
wfurt
left a comment
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
| } | ||
| }; | ||
|
|
||
| TaskScheduler.UnobservedTaskException += eventHandler; |
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.
Unrelated to getting this PR in, but do you think it would be worthwhile to register this handler for all our tests? I'm actually thinking about doing this for S.N.Quic as we did have UnobservedTask issues reported in the past.
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.
Yes, we should (probably both Http and Quic).
FWIW the reason the test does filtering on the exception message is because of other unobserved exceptions from Quic 😄
I'll check if I can repro it again.
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.
I've reopened #80111 (comment)
Fixes #104324
We have two places where we set
_readAheadTask:CheckUsabilityOnScavenge(zero-byte read + fancy synchronization around_readAheadTaskStatus)PrepareForReuse(simpleReadAsync(readBuffer)right before we start writing a request to an existing connection)#80214 fixed leaking unobserved exceptions with the former while reintroducing a similar issue with the latter.
In
PrepareForReuse, the contract is that the caller will either:PrepareForReusereturnedtruefalseIn the case where the task completed immediately, we would dispose the connection, but we weren't observing the potential exception from the read-ahead task.