angular: Error thrown by rxjs observer not always sent to ErrorHandler.handleError

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@ccrowhurstram , thank you for posting the issue, current https://github.com/angular/zone.js/pull/843 patch doesn’t fully fix your issue, I have made a new PR (https://github.com/angular/zone.js/pull/884) to fix this one, I have test my idea and it should work.