Skip to content

Tap kills the Subject on unsubscription #7078

Description

@voliva

Describe the bug

When using tap passing in a Subject directly (i.e. without using { next, error, complete }), if the resulting observer creates a subscription and unsubscribes from it, then the Subject is also unsubscribed: If a new subscriber comes, it will throw an ObjectUnsubscribedError.

I've bisected this happened somewhere in between 7.2.0 and 7.3.0

Expected behavior

When the resulting subscription is closed, the Subject should not be killed: The new subscription should work just as fine as the initial one.

Reproduction code

const subject = new Subject();

interval(1000).pipe(
  tap(subject),
  take(2),
  repeat(2)
).subscribe(v => console.log(v))

Reproduction URL

https://stackblitz.com/edit/rxjs-a9l4j2?file=index.ts

Version

7.3.0

Environment

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

7.xIssues and PRs for version 7.x8.xIssues and PRs for version 8.xAGENDA ITEMFlagged for discussion at core team meetingsbugConfirmed bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions