Skip to content

shareReplay not cleaning up subscriptions. #3336

@benlesh

Description

@benlesh

RxJS version: 5 or 6

Code to reproduce:

const source = interval(1000).pipe(
  tap(() => console.log('tick'),
  shareReplay(1),
);

const sub = source.subscribe(x => console.log(x));

sub.unsubscribe();

Expected behavior:

It should never log "tick"

Actual behavior:

It TOTALLY logs "tick".

Additional information:

shareReplay should definitely not recycle the underlying ReplaySubject when refCount drops to 0 due to unsubscription. However, it should end the subscription, which it's currently not doing, because I'm a dolt.

It should be an easy fix.

Metadata

Metadata

Assignees

Labels

bugConfirmed bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions