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

Allow opt-out from TaskScheduler.UnobservedExceptions #1910

Closed

Conversation

idg10
Copy link
Collaborator

@idg10 idg10 commented Apr 6, 2023

NOTE: we are more likely to go with #1914 instead now. A problem with the approach in this PR is that it creates additional opportunities for overload resolution ambiguity, so although this is a binary-compatible change, it might cause build errors when people upgrade.

Resolves #1256

Various Rx operators and extension methods can wrap a Task as an IObservable<T>. Historically, if you unsubscribe before the task is finished and the task subsequently fails, the resulting exception pops out through TaskScheduler.UnobservedException.

There is a point of view that this is inconsistent with how we cope with exceptions in things like Select projection callbacks that occur after unsubscription - those are just swallowed.

This PR provides the ability to ask for these kinds of orphaned exceptions to be ignored when they occur in tasks, just like they are in other scenarios.

The default behaviour does not change because that would break applications depending on the UnobservedException event. This adds new overloads enabling opting out.

…e swallowed

Added tests verifying that the old behaviour continues to be the default, and that the new overloads provide the new behaviour when asked for it. (The tests for the latter fail right now because we've not actually changed the implementation yet. Also, the Qbservable API parity tests also fail because we've not yet updated the homoiconicity support to match the new surface area.)
@idg10 idg10 self-assigned this Apr 6, 2023
@idg10 idg10 linked an issue Apr 6, 2023 that may be closed by this pull request
@quinmars
Copy link
Contributor

quinmars commented Apr 7, 2023

It's a pity that the default setting is exactly what most people don't want, but I understand your sentiment about backwards compatibility.

@idg10
Copy link
Collaborator Author

idg10 commented Apr 19, 2023

Went with #1914 instead

@idg10 idg10 closed this Apr 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Observable.FromAsync produces unobserved task exceptions
2 participants