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

shareReplay with refCount restarts with synchronous sources #5548

Closed
josepot opened this issue Jul 1, 2020 · 1 comment
Closed

shareReplay with refCount restarts with synchronous sources #5548

josepot opened this issue Jul 1, 2020 · 1 comment

Comments

@josepot
Copy link
Contributor

josepot commented Jul 1, 2020

Bug Report

Current Behavior
shareReplay with refCount restarts with synchronous sources

Reproduction

  • REPL or Repo link:

I can't use stackblitz because since the latest release doesn't have #5521 then that bug masks the other one, but with the current code on master, this would happen:

const foo$ = from([1, 2, 3, 4, 5]).pipe(
  shareReplay({ refCount: true, bufferSize: 1})
)

foo$.subscribe(x => {
  console.log(x);
})
// 1
// 2
// 3
// 4
// 5

foo$.subscribe(x => {
  console.log(x);
})
// 1
// 2
// 3
// 4
// 5

Expected behavior
The second subscribe should only emit 5

Possible Solution
In this line also check that the subscription isn't closed:

if (subscription && !subscription.closed && useRefCount && refCount === 0) {

Additional context
See this comment from @leggechr and the comments afterwords.

@josepot
Copy link
Contributor Author

josepot commented Jul 2, 2020

I'm closing this issue because it was addressed by #5549

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

No branches or pull requests

1 participant