Skip to content

Error thrown by rxjs observer not always sent to ErrorHandler.handleError #14316

@christianacca

Description

@christianacca

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting

Current behavior
Error thrown in an observable is not sent to the ErrorHandler.handleError method when observeOn(Scheduler.asap) is used.

Take the following example that DOES result in an error being sent:

    const ticks$ = Observable.interval(1000).take(10);
    
    this.mapped$ = ticks$.map(value => {
      if (value === 3) {
        throw new Error('oops');
      }
      return { value };
    });
<h4>Mapped ticks from an observable... {{mapped$ | async | json}}</h4>

The following example that does NOT result in an error being sent:

    const ticks$ = Observable.interval(1000).take(10)
      .observeOn(Scheduler.asap);
      
    this.mapped$ = ticks$.map(value => {
      if (value === 3) {
        throw new Error('oops');
      }
      return { value };
    });

Expected behavior

An error thrown by an observer scheduled with Scheduler.asap is sent to ErrorHandler.handleError

Minimal reproduction of the problem with instructions*

I've reproduced the problem in a new angular seed project generated by the latest vs of angular-cli (1.0.0-beta.30).

To run:

Notice that the error thrown by the map operator is logged to the console, but not sent to DelegatingErrorHandler.handleError (a custom ErrorHandler)

What is the motivation / use case for changing the behavior?

Using observeOn(Scheduler.asap) is a workaround to a problem with rxjs as documented here:

https://medium.com/@benlesh/on-the-subject-of-subjects-in-rxjs-2b08b7198b93#3114

Please tell us about your environment:

  • Windows 10

  • Visual Studio code

  • Angular version: 2.4.6

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Only tried in Chrome 55.0.2883.87

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

TypeScript 2.0.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: zonesIssues related to zone.js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions