Rxjs: errors do not terminate source unless an observer is provided

Created on 5 Sep 2016  路  7Comments  路  Source: ReactiveX/rxjs

Observable.interval(1000)
  .flatMap(() => this.http.get('abc'))
  .subscribe(
      // x => console.log('Next: ' + x) // Don't terminite without this.
  );

This http request gives an error due to 404. But the stream keeps polling.

However, as soon as I uncomment the commented line in subscribe, it terminates on the first error.

See example here

http://plnkr.co/edit/bQyBvboFJCPyZUEFjraX?p=preview

Why is that?

bug

All 7 comments

Appears this isn't related to flatMap, it's more general than that. If you don't provide an observer to subscribe(observer) then the source does not terminate correctly.

Still digging, but here's my minimal example:

http://jsbin.com/yayave/edit?js,output

So far my best guess is it's related to the internal syncErrorThrowable, whether it's true or false. Not providing an observer it gets the default empty observer which is syncErrorThrowable: false but when you provide your own its syncErrorThrowable: true. This logic is seemingly for optimizing try/catch.

@blesh this prolly needs your attention since I believe you're the one who knows this part best.

@jayphelps I'm responsible for syncErrorThrowable, so I'll dig into this one.

@trxcllnt this is all YOUR FAULT!

@jayphelps I may have authored the code, but syncErrorThrowable is the product of a debate on error handling semantics that I lost, so I'm going to blame @blesh and @zenparsing :-)

@jayphelps @colinfang fixed in #1935

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dooreelko picture dooreelko  路  3Comments

cartant picture cartant  路  3Comments

LittleFox94 picture LittleFox94  路  3Comments

Agraphie picture Agraphie  路  3Comments

Zzzen picture Zzzen  路  3Comments