dotnet / dotnet/reactive

Prevent fail-fast (crashing the AppDomain) from happening

Open
#265 2 comments 0 reactions 0 assignees View on GitHub
[area] Rx enhancement needs design
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

With Rx (and Tasks in general), it's easy to write code which will be executed in various (threading) contexts.
Previously "fail-fast" was the norm in .Net (it still largely is because of legacy), and `ThreadPool` respects that (un-catched exceptions in scheduled actions will kill your app).
But [since .Net 4.5](https://blogs.msdn.microsoft.com/pfxteam/2011/09/28/task-exception-handling-in-net-4-5/), `TaskPool` has a different behavior (which is good, I can elaborate the reasons if needed).

This request is to prevent any fail-fast from happening in Rx and fix scenarios where:
`Observable.Return(Unit.Default).ObserveOn(TaskPool).Subscribe(_ => throw new Exception())`
wouldn't kill the app, but
`Observable.Return(Unit.Default).ObserveOn(ThreadPool).Subscribe(_ => throw new Exception())`
will.

Given the schedulers are async, the exception can't be thrown to caller, and it _needs_ to be provided to some event for troubleshooting (only thing worse than fail-fast is exception hiding), which happens with `TaskPool` through `TaskScheduler.UnobservedTaskException`

Currently with Rx 2.2.5 we can achieve that by customizing the PlatformEnlightmentProvider, but goal is to get rid of it.

For reference our unit tests which are passing with the modified provider:
https://gist.github.com/gluck/5676596e6d321089b9841bd16debd390

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.