-
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
forEach should unsubscribe if callback function throws #1411
Comments
Ah... good catch, thank you @zenparsing! |
Actually, @zenparsing, looking at your reference implementation, there's a tricky bit your not covering... consider this: const syncObservable = new Observable((observer) => {
const expensiveThing = new ExpensiveThing();
observer.next('I am a little teapot!');
return () => expensiveThing.destroy();
});
syncObservable.forEach(x => {
throw new Error('dammit, I am a sugar bowl');
}); In the case above, the error will be thrown synchronously before I haven't tested this, but I think that's what will happen. I'm working up a solution for RxJS 5 now. |
Yeah, I was trying to simplify the algorithm by letting the error propagate in synchronous case, but clearly I messed it up : ) |
@zenparsing we had to go to quite a bit of trouble to ensure that both a. the source unsubscription logic is run and b. the error is thrown to outside consumers when a next/error/complete handler throws on synchronous dispatch. |
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. |
Test case:
Expected result: Only "1" is logged.
Actual result: "1" and "2" are logged.
I recently fixed this issue over on es-observable:
The text was updated successfully, but these errors were encountered: