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

feat: stopped notification handler #5750

Merged
merged 21 commits into from
Oct 31, 2020

Conversation

cartant
Copy link
Collaborator

@cartant cartant commented Sep 24, 2020

Description:

@benlesh

This PR is a WIP representation of what I would like to see implemented as a replacement for the canReportError shenanigans - which I would delete as part of this being merged.

The fundamental problem is that errors reported to stopped subscribers are swallowed and no mechanism is offered to RxJS developers to let them alter this behaviour. ATM, there is one place - in the try/catch that surrounds the subscribe within Observable - at which the chain of subscribers is traversed to determine whether or not any are stopped/closed and whether the error can be reported. This is pretty crappy - I feel comfortable saying this, because I wrote the code. 😅

I would prefer to ditch the traversal entirely and, instead, offer a configuration point that can be used to register a handler for notifications sent to stopped observers. This would be more general than the traversal that currently happens - I can see it being useful in the DevTools - and would certainly be simpler. IMO, this shouldn't really impact anyone. ATM, in v6, errors that cannot be reported are written to the console; it's only in v7 that an error is actually thrown. Also, to my knowledge, this error swallowing has only ever affected me - when investigating two bugs in the RxJS core.

What are your thoughts on this? AFAICT, it the wiring up of the stopped-notification handler only needs to happen in Subscriber#next/error/complete. If you want me to go ahead with this, I can add some tests and can remove canReportError, etc.

IMO, this doesn't have to be perfect; it just has to be better than the traversal - and that shouldn't be too hard. 😅

Related issue (if exists): None

src/internal/config.ts Outdated Show resolved Hide resolved
src/internal/Subscriber.ts Outdated Show resolved Hide resolved
src/internal/Subscriber.ts Outdated Show resolved Hide resolved
src/internal/Subscriber.ts Outdated Show resolved Hide resolved
src/internal/config.ts Outdated Show resolved Hide resolved
@cartant cartant changed the title WIP: feat: stopped notification handler feat: stopped notification handler Sep 26, 2020
@cartant cartant marked this pull request as ready for review September 26, 2020 02:15
Copy link
Member

@benlesh benlesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really just that re-export needs to be changed, IMO.

And I've left an open question about the setTimeout we might want to discuss (but I don't think it should block a merge)

src/internal/Notification.ts Outdated Show resolved Hide resolved
src/internal/Subscriber.ts Outdated Show resolved Hide resolved
src/internal/config.ts Show resolved Hide resolved
@benlesh
Copy link
Member

benlesh commented Sep 29, 2020

Also needs a rebase it seems.

src/internal/Subscriber.ts Outdated Show resolved Hide resolved
src/internal/config.ts Outdated Show resolved Hide resolved
Copy link
Member

@benlesh benlesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions, but one easy to fix issue.

src/internal/util/reportUnhandledError.ts Outdated Show resolved Hide resolved
@cartant
Copy link
Collaborator Author

cartant commented Oct 2, 2020

Addressed comments.

Copy link
Member

@benlesh benlesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one spot that could probably use a comment or two... Otherwise LGTM. Squash and merge whenever you're ready.

src/internal/testing/TestScheduler.ts Show resolved Hide resolved
@cartant cartant merged commit cfa267b into ReactiveX:master Oct 31, 2020
@cartant cartant deleted the stopped-notification branch November 6, 2020 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants