Skip to content

Commit

Permalink
Suppress unobserved task exceptions for channel Completion tasks (dot…
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub authored Feb 5, 2023
1 parent 8521541 commit a904ec3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ internal static void Complete(TaskCompletionSource tcs, Exception? error = null)
}
else if (error != null && error != s_doneWritingSentinel)
{
tcs.TrySetException(error);
if (tcs.TrySetException(error))
{
// Suppress unobserved exceptions from Completion tasks, as the exceptions will generally
// have been surfaced elsewhere (which may end up making a consumer not consume the completion
// task), and even if they weren't, they're created by a producer who will have "seen" them (in
// contrast to them being created by some method call failing as part of user code).
_ = tcs.Task.Exception;
}
}
else
{
Expand Down

0 comments on commit a904ec3

Please sign in to comment.