Avoid UnobservedTaskExceptions from HttpConnection.PrepareForReuse#104335
Merged
MihaZupan merged 2 commits intodotnet:mainfrom Jul 3, 2024
Merged
Avoid UnobservedTaskExceptions from HttpConnection.PrepareForReuse#104335MihaZupan merged 2 commits intodotnet:mainfrom
HttpConnection.PrepareForReuse#104335MihaZupan merged 2 commits intodotnet:mainfrom
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/ncl |
This was referenced Jul 3, 2024
Open
ManickaP
reviewed
Jul 3, 2024
| } | ||
| }; | ||
|
|
||
| TaskScheduler.UnobservedTaskException += eventHandler; |
Member
There was a problem hiding this comment.
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.
Member
Author
There was a problem hiding this comment.
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.
ManickaP
approved these changes
Jul 3, 2024
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.
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.