Skip to content

Prevent fail-fast (crashing the AppDomain) from happening #265

Open
@gluck

Description

@gluck

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, 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions