-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Errors thrown in Subscriber's next handler should call unsubscribe logic #1186
Comments
Digging into this, I'm not sure this can be implemented reliably. This is because any synchronous call to const source = new Observable(observer => {
// start some expensive async thing
var id = asyncThing((x => observer.next(x));
// synchronously emit a value (that will throw ultimately)
observer.next('wee');
// return teardown logic for expensive async thing
return () => {
cancelAsyncThing(id);
};
});
source.subscribe((x) => {
if (x === 'wee') {
throw new Error('stop having fun!');
}
}); In the above, There's basically no way to get this to work consistently unless all Observable implementations had a try/finally block. I'm not sure what we should do for expected behavior here. But I think it should be consistent so as not to surprise developers. |
I suppose we could squelch all |
@Blesh resolved in #1191. It also resolves some of @mattpodwysocki and @zenparsing's concerns about the difference between using callbacks and a duck-typed Observer object. |
@trxcllnt did you happen to test perf before and after? I suspect that adding several conditionals and a few function calls to each emission is going to impact performance. |
@Blesh I ran |
This is tricky, because the ideal behavior is to halt execution of the subscription logic and teardown only what's been subscribed to at that point. In effect, it would almost be better to have teardown logic added to |
…-land handlers. - slightly improves perf by improving shape of SafeSubscriber so JIT can optimize call patterns. related #1186
This was resolved by #1191. |
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. |
It was supposed to be this way in Rx 4.0.6, according to @mattpodwysocki ... but when I tried it it didn't work out that way.
The text was updated successfully, but these errors were encountered: