-
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 swallowed in stopped subscribers #3461
Comments
This is by design. If a Subscriber has already been notified of completion or error, we do not want it to be notified again in a reentrant way. |
But should the error be completely ignored - i.e. not re-thrown or otherwise ensured to be unhandled? At the moment, the implementation of |
It's sometimes possible for operator implementations to effect calls to `error` after `unsubscribe` has been called - i.e. when the subscriber is stopped. See ReactiveX#3444. Prior to this commit, such errors were swallowed. Closes ReactiveX#3461
The problem is in the implementation of protected _trySubscribe(sink: Subscriber<T>): TeardownLogic {
try {
return this._subscribe(sink);
} catch (err) {
if (config.useDeprecatedSynchronousErrorHandling) {
sink.syncErrorThrown = true;
sink.syncErrorValue = err;
}
sink.error(err);
}
} If there is a subscriber in the list of sinks - the subscribers chained together using the The only way that I can see that this could be fixed would be to walk the chain of subscribers and if a closed/stopped subscriber is found, rethrow the error or call |
If _trySubscribe catches an error and the sink - or one of its destinations - is stopped and the sink's error method is called, the error is swallowed - as it cannot be reported via the observer's callback. This commit adds an internal reportError method to Subscriber. The method defers to the appropriate error reporting mechanism if a stopped subscriber is found. Closes ReactiveX#3461
If _trySubscribe catches an error and the sink - or one of its destinations - is stopped and the sink's error method is called, the error is swallowed - as it cannot be reported via the observer's callback. This commit adds an internal reportError method to Subscriber. The method defers to the appropriate error reporting mechanism if a stopped subscriber is found. Closes ReactiveX#3461
If _trySubscribe catches an error and the sink - or one of its destinations - is stopped and the sink's error method is called, the error is swallowed - as it cannot be reported via the observer's callback. This commit adds an internal reportError method to Subscriber. The method defers to the appropriate error reporting mechanism if a stopped subscriber is found. Closes ReactiveX#3461
So to clarifiy, you're saying that in this case: new Observable(subscriber => {
subscriber.error(new Error('first one'));
subscriber.error(new Error('second one'));
})
.subscribe({
error(err) { console.log(`handled ${err.message}`); }
}); We should see the first one log as handled, and the second one should be rethrown (in another callstack)? |
I've just realised that I've replied to the above comment - which I read in an email - here, in the related PR conversation. |
This issue probably should be closed. I'll create a new issue that better describes the repro and motivation - if I can't recall it myself, this issue is unhelpful - and will include a snippet similar the one in this comment that instead reports errors to the console if they cannot be reported to the observer. |
Closing this in favour of #3803 - which is, hopefully, a more clear description of the problem. |
RxJS version: 6.0.0-beta.1
Code to reproduce: See #3444
Expected behavior:
Errors should not be swallowed.
Actual behavior:
Errors are swallowed.
Additional information:
The
Subscriber.prototype.error
implementation:swallows any errors that are passed to a stopped subscriber.
See #3444 for a repro. The internal error is swallowed because the subscriber to which it is passed is stopped at the time the error occurs.
The text was updated successfully, but these errors were encountered: