Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Subscriber): creates subscriber throwable by default #2865

Closed
wants to merge 1 commit into from

Conversation

kwonoj
Copy link
Member

@kwonoj kwonoj commented Sep 25, 2017

Description:

I have gut feeling this might not be appropriate fix, feel free to close.

This PR ensure subscriber created internally have nested parents (i.e CombineLatestSubscriber has Mergemap as parents, etcs) are having proper syncErrorThrown behavior. Previously it bypasses setting syncError* property as well as wrapping it into safesubscriber, allows some of cases errors are not thrown but just swallowed.

Related issue (if exists):

@kwonoj
Copy link
Member Author

kwonoj commented Sep 25, 2017

/cc @benlesh

@kwonoj
Copy link
Member Author

kwonoj commented Sep 25, 2017

lol this makes whole test cases fail, not sure why I couldn't caught in local test.

@rxjs-bot
Copy link

rxjs-bot commented Sep 25, 2017

Messages
📖

CJS: 1342.5KB, global: 737.3KB (gzipped: 137.9KB), min: 144.6KB (gzipped: 30.7KB)

Generated by 🚫 dangerJS

@kwonoj kwonoj changed the title fix(Subscriber): creates safesubscriber for internal subscribers fix(Subscriber): creates subscriber throwable by default Sep 25, 2017
@kwonoj
Copy link
Member Author

kwonoj commented Sep 26, 2017

even if this is accepted it'll be probably 5 only and not being cherrypicked into next branch as planned breaking changes.

@benlesh
Copy link
Member

benlesh commented Sep 26, 2017

I'm not sure about this one... it seems like it will make syncError tracking occur within operators, which I'm pretty sure isn't necessary (which is why the current code avoids it explicitly).

Either way, error rethrowing is going away in 6.0 to reach compliance with the proposal, and to prevent some really, really nasty errors like:

// imagine we're shipping this off to a few third parties
const source$ = Observable.interval(1000).share();

// third party 1
source$.map(x => x + x).subscribe(x => console.log(x));

// third party 2
source$.filter(x => {
  if (x > 3) throw new Error('haha');
  return x <= 3;
})
.subscribe(x => console.log(x));

// third party 3
source$.mergeMap(x => Observable.timer(x))
  .subscribe(x => console.log(x))

... what's going to happen above is on the fifth emission, the number 4 hits "third party 2", which throws an error, the error propagates down to the final subscriber, is unhandled, then is rethrown. The rethrown error unwinds the stack back to the loop in the share() that is notifying everyone for the multicast. That loop breaks, stopping notifications from being sent to anyone else. This is producer interference.

There are other reasons too... Like how are you going to try { } catch { } an error that is thrown asynchronously?

In the end, in v6, we will have a notification channel for unhandled errors, and we'll need to remove the rethrowing behavior.

@kwonoj
Copy link
Member Author

kwonoj commented Sep 26, 2017

I'm not sure about this one

Yes, reason I mentioned in PR I have gut feeling this might not be appropriate fix, feel free to close. :)

it seems like it will make syncError tracking occur within operators, which I'm pretty sure isn't necessary

Most cases it's true, refer issue #2813 for some higher order observable cases with asynchronously scheduled. As I said already above I have feeling this might not appropriate fix, but we do currently have completely swalloing exception and doesn't deliver it into top level observer.

In the end, in v6, we will have a notification channel for unhandled errors, and we'll need to remove the rethrowing behavior.

Absolutely, issue should be v5 targeted fix as mentioned even if this is accepted it'll be probably 5 only and not being cherrypicked into next branch as planned breaking changes.

@benlesh
Copy link
Member

benlesh commented Dec 13, 2017

I'm trying to decide if this solves #3183 or not.

@kwonoj
Copy link
Member Author

kwonoj commented Dec 13, 2017

@benlesh worth peek #3161 as well, I have guess that might be more feasible to try out. This PR is too ad-hoc honestly.

@jayphelps
Copy link
Member

did #3161 solve the same problem?

@benlesh
Copy link
Member

benlesh commented Jan 12, 2018

Yes, #3161 solved the same problem. I think we can close this. @kwonoj, please verify, and open it up if I'm mistaken.

@benlesh benlesh closed this Jan 12, 2018
@coveralls
Copy link

Coverage Status

Coverage remained the same at ?% when pulling 9309bae on kwonoj:fix-syncthrowable into 2e576dc on ReactiveX:master.

@lock
Copy link

lock bot commented Jun 5, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
@kwonoj kwonoj deleted the fix-syncthrowable branch October 4, 2019 05:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Errors sometimes not rethrown
5 participants