Skip to content
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

[release/6.0] Fix UnobservedTaskException from SemaphoreSlim.WaitAsync #61491

Merged
merged 2 commits into from
Nov 15, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Nov 12, 2021

Backport of #60890 to release/6.0

/cc @stephentoub

Customer Impact

If a developer uses SemaphoreSlim.WaitAsync with a timeout and it times out, the TaskScheduler.UnobservedTaskException event will erroneously be raised with a TimeoutException due to the exception that gets generated internally. This ends up being noise in an event devs typically use to know when something they're supposed to have handled has gone unhandled.

Testing

Manual testing plus a new unit test.

Risk

Low.

If a SemaphoreSlim.WaitAsync times out, it correctly returns false, but it also results in TaskScheduler.UnobservedTaskException being raised unexpectedly, due to internal use of a faulted task whose exception isn't observed.  This fixes that by marking any such exceptions as having been observed.
@ghost
Copy link

ghost commented Nov 12, 2021

Tagging subscribers to this area: @mangod9
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #60890 to release/6.0

/cc @stephentoub

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Threading

Milestone: -

@stephentoub stephentoub added the Servicing-consider Issue for next servicing release review label Nov 12, 2021
@stephentoub stephentoub added this to the 6.0.x milestone Nov 12, 2021
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, big thanks for providing the fix and backporting it!

@danmoseley danmoseley added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Nov 15, 2021
@danmoseley danmoseley merged commit 09e3dcb into release/6.0 Nov 15, 2021
@danmoseley danmoseley deleted the backport/pr-60890-to-release/6.0 branch November 15, 2021 04:14
@ghost ghost locked as resolved and limited conversation to collaborators Dec 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Threading Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants