ReactiveX / rxjs

A reactive programming library for JavaScript
https://rxjs.dev
Apache License 2.0
30.7k stars 3k forks source link

Remove tryOrOnError from subscription #1135

Closed benlesh closed 8 years ago

benlesh commented 8 years ago

Somehow we missed this, but in order to comply with the es-observable spec, and in order not to confuse RxJS 4 users more than we already have, errors thrown in the next handler shouldn't jump to the error handler:

Observable.of('hi').subscribe(() => {
  throw 'haha!';
}, (err) => {
  // THIS SHOULD NEVER BE HIT.
});

It should just throw.

headinthebox commented 8 years ago

Here is a small "test" that show the .NET behavior

namespace RxTests
{
    class MainClass
    {

        public static void Main (string[] args)
        {
            var d = (CompositeDisposable) Observable.Interval (TimeSpan.FromSeconds (1))
                .Subscribe(x => { 
                    if(x > 3) { 
                        throw new Exception("..."); 
                    } else { 
                        Console.WriteLine(x); 
                    }}, e => { Console.WriteLine(e.Message); });

            d.Add(Disposable.Create(()=>{ Console.WriteLine("?????");}));

            Console.ReadKey ();
        }
    }   
}

Output uncaught exception and

0
1
2
3
?????
mattpodwysocki commented 8 years ago

@headinthebox correct, it should conform to the AutoDetachObserver as we've had which protects the OnNext calls and disposes, then throws.

lock[bot] commented 6 years ago

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.