-
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
finally() not consistently called in case of unhandled error #3171
Comments
A similar thing is discussed here: #3004. The actual behavior is what I would expect to happen in my opinion. |
@martinsik, OK. I personally find this behavior surprising. |
@trevorade This is a byproduct of "producer interference" The issue is that when you don't have an error handler in your In RxJS 6 (currently in master), this is avoided by using a strategy called HostReportErrors, that basically rethrows the error in a setTimeout, giving it it's own callstack. Again, this is only in the case were an error is completely unhandled. |
Closing, because it's fixed in v6, and we can't change it in v5 without making a breaking change for others. |
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. |
RxJS version: 5.5.3
Code to reproduce:
Please reference this JSFiddle for an interactive reproduction of this issue:
http://jsfiddle.net/trevorade/gu8v3ma5/
Specifically, I take issue with this:
Expected behavior:
"First finally called" and "Second finally called" are both logged.
Actual behavior:
Only "First finally called" is logged. Which implies that the second finally linked to a subscription of the Observable is not called.
Additional information:
Here's a workaround for the problem:
Now that the first subscription has an
error
callback, the second subscription is processed resulting in the secondfinally
callback being called.The ideal behavior would be that, even if an exception is not handled by a previous subscription, subsequent subscriptions would still be called (including any error handling or
finally
callbacks).Referring to the repro demo again: http://jsfiddle.net/trevorade/gu8v3ma5/, there are several combinations of error handling present or absent that I take issue with. I'll explain the issues per combination:
True/true works correctly. This is one of the work-around cases.
With, true/false both
finally
callbacks are called which is called. Unfortunately, an exception is surfaced at the location wheresubscribe.error
is called. This may be desirable behavior but may also be confusing. I feel this is a separate issue though.This is a pretty broken case where the second error handler doesn't get a chance to process the error because the first subscription didn't. Also, only the first finally is called, not both.
With no error handling incorporated into the subscriptions, only the first finally is called. This is also unexpected and undesirable.
The text was updated successfully, but these errors were encountered: