Skip to content

Commit

Permalink
fix(subscriber): don't unsubscribe self
Browse files Browse the repository at this point in the history
When unsubscribing a subscriber's parent, make sure that the subscriber
itself is not unsubscribed.

Closes ReactiveX#4095
  • Loading branch information
cartant committed Sep 6, 2018
1 parent 5d92a9b commit 9d92281
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/internal/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ export class Subscriber<T> extends Subscription implements Observer<T> {
/** @deprecated This is an internal implementation detail, do not use. */
_unsubscribeParentSubscription() {
if (this._parentSubscription !== null) {
++this._keepAliveCount;
this._parentSubscription.unsubscribe();
--this._keepAliveCount;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/internal/Subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class Subscription implements SubscriptionLike {
/** @internal */
protected _parents: Subscription[] = null;
/** @internal */
protected _keepAliveCount: number = 0;
/** @internal */
private _subscriptions: SubscriptionLike[] = null;

/**
Expand All @@ -45,7 +47,6 @@ export class Subscription implements SubscriptionLike {
constructor(unsubscribe?: () => void) {
if (unsubscribe) {
(<any> this)._unsubscribe = unsubscribe;

}
}

Expand All @@ -59,7 +60,7 @@ export class Subscription implements SubscriptionLike {
let hasErrors = false;
let errors: any[];

if (this.closed) {
if (this.closed || this._keepAliveCount > 0) {
return;
}

Expand Down

0 comments on commit 9d92281

Please sign in to comment.