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

Fix 6805: remove strange groupBy behavior #7252

Merged

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented Apr 17, 2023

fix(groupBy): will no longer leak inner subscriptions

groupBy no longer supports the behavior where inner subscriptions will cause the outer subscription to stay connected after consumer unsubscribes from result.

Resolves #6805

BREAKING CHANGE: groupBy no longer allows grouped observable subscriptions to stay connected after parent subscription unsubscribed. If you need this behavior, don't unsubscribe from the parent.

refactor: Remove direct instantiation of OperatorSubscriber

  • Stopped exporting OperatorSubscriber class from module
  • Updated onErrorResumeNext and a Subject test to use createOperatorSubscriber

Actual stream of the work is here, if that helps: https://youtu.be/rHgED1U6XDY

`groupBy` no longer supports the behavior where inner subscriptions will cause the outer subscription to stay connected after consumer unsubscribes from result.

Resolves ReactiveX#6805

BREAKING CHANGE: `groupBy` no longer allows grouped observable subscriptions to stay connected after parent subscription unsubscribed. If you need this behavior, don't unsubscribe from the parent.
+ Stopped exporting `OperatorSubscriber` class from module
+ Updated `onErrorResumeNext` and a `Subject` test to use `createOperatorSubscriber`
@niklas-wortmann niklas-wortmann requested review from niklas-wortmann and removed request for niklas-wortmann April 18, 2023 23:26
Copy link
Member

@jakovljevic-mladen jakovljevic-mladen left a comment

Choose a reason for hiding this comment

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

LGTM, only one comment from the code needs to be updated.

Comment on lines 168 to 174
// Capturing a reference to this, because we need a handle to it
// in `createGroupedObservable` below. This is what we use to
// subscribe to our source observable. This sometimes needs to be unsubscribed
// out-of-band with our `subscriber` which is the downstream subscriber, or destination,
// in cases where a user unsubscribes from the main resulting subscription, but
// still has groups from this subscription subscribed and would expect values from it
// Consider: `source.pipe(groupBy(fn), take(2))`.
Copy link
Member

Choose a reason for hiding this comment

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

Revisit this comment.

Copy link

@ktrz ktrz left a comment

Choose a reason for hiding this comment

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

I've added one additional note about a comment that probably needs revisiting. Other than that LGTM

// Capturing a reference to this, because we need a handle to it
// in `createGroupedObservable` below. This is what we use to
// subscribe to our source observable. This sometimes needs to be unsubscribed
// out-of-band with our `subscriber` which is the downstream subscriber, or destination,
// in cases where a user unsubscribes from the main resulting subscription, but
// still has groups from this subscription subscribed and would expect values from it
// Consider: `source.pipe(groupBy(fn), take(2))`.
const groupBySourceSubscriber = new OperatorSubscriber(
const groupBySourceSubscriber = createOperatorSubscriber(
subscriber,
(value: T) => {
// Because we have to notify all groups of any errors that occur in here,
Copy link

Choose a reason for hiding this comment

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

GH didn't allow me to put a comment in the exact spot lines 189-191 here but I think the comment also needs revisiting as the mentioned reference counting seem to be removed now.

@benlesh benlesh merged commit 9ed27bf into ReactiveX:master May 15, 2023
3 checks passed
@benlesh benlesh deleted the fix-6805_remove-strange-groupBy-behavior branch May 15, 2023 21:53
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.

Should groupBy keep connections after the result subscription is unsubscribed?
3 participants