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

`BehaviorSubject` and `ReplaySubject` don't clean up subscribers immediately if subscription is stopped #147

Closed
xicmiah opened this Issue May 16, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@xicmiah
Copy link

commented May 16, 2016

Subscriber instances created by running Observable#firstL on hot observable (at least with BehaviorSubject) get cleaned up only when underlying observable pushes an element.

Reproducible example: https://gist.github.com/xicmiah/bfcf9dac0c74db8904018b37a5e3b96a

@alexandru

This comment has been minimized.

Copy link
Member

commented May 16, 2016

I can confirm. Some notes:

  • this isn't Observable.firstL that leaks, the problem being in the implementation of BehaviorSubject (and ReplySubject)
  • basically if an initial state needs to be served, the implementation doesn't notice the subscriber stopped until the next event is sent
  • this becomes noticeable with BehaviorSubject when you take(1), which is basically what firstL is doing
  • fix is easy, will make it in the next release

Thanks @xicmiah for taking the time to investigate. The hint with ConnectableSubscriber pinpointed the problem.

@alexandru alexandru changed the title `Observable#firstL` doesn't clean up subscribers `BehaviorSubject` and `ReplaySubject` don't clean up subscribers immediately if subscription is stopped May 16, 2016

@alexandru alexandru added the bug label May 16, 2016

@alexandru alexandru added this to the 2.0-RC3 milestone May 16, 2016

@alexandru alexandru self-assigned this May 16, 2016

@alexandru

This comment has been minimized.

Copy link
Member

commented May 25, 2016

Fixed and released in 2.0-RC3

@alexandru alexandru closed this May 25, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.