Observe a connect given up on - #875
Merged
Merged
Conversation
ViewerClient.IsOwned and the synchronous TrySend wait on ConnectAsync for a bounded time, inside a using. A connect given up on is still pending when the client is disposed, and faults once that tears it down - or, where the port refuses rather than hangs, when the refusal arrives - with nobody left to observe it. The finalizer then reported it as an unobserved task exception. That is routine rather than rare. The launch gate probes IsOwned while a viewer it has just started is still binding, and on Windows a connect to a port nothing is listening on is not refused at once, so the half second wait expires. Running ViewerLaunchTests.AcceptAllOverALongQueue printed two of them, and any test process that launches the viewer gets the same, fatally in a host that treats unobserved task exceptions as fatal. Both sites now connect through one helper, which observes the abandoned task with a continuation. The timeouts, and what Found records, are unchanged. AConnectGivenUpOnIsObserved gives up on five connects with a zero wait, which abandons them whatever the platform does with a closed port, then collects and asserts nothing was reported. It fails on the old code on net10 and net48.
This was referenced Sep 22, 2026
Merged
Merged
Merged
This was referenced Sep 23, 2026
Merged
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
ViewerClient.IsOwned and the synchronous TrySend wait on ConnectAsync for a bounded time, inside a using. A connect given up on is still pending when the client is disposed, and faults once that tears it down - or, where the port refuses rather than hangs, when the refusal arrives - with nobody left to observe it. The finalizer then reported it as an unobserved task exception.
That is routine rather than rare. The launch gate probes IsOwned while a viewer it has just started is still binding, and on Windows a connect to a port nothing is listening on is not refused at once, so the half second wait expires. Running ViewerLaunchTests.AcceptAllOverALongQueue printed two of them, and any test process that launches the viewer gets the same, fatally in a host that treats unobserved task exceptions as fatal.
Both sites now connect through one helper, which observes the abandoned task with a continuation. The timeouts, and what Found records, are unchanged.
AConnectGivenUpOnIsObserved gives up on five connects with a zero wait, which abandons them whatever the platform does with a closed port, then collects and asserts nothing was reported. It fails on the old code on net10 and net48.