Skip to content

Commit

Permalink
fix: check for interop subscriptions
Browse files Browse the repository at this point in the history
Closes #5237
  • Loading branch information
cartant committed Apr 23, 2020
1 parent b4c9d83 commit aa4c11f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/internal/operators/finalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ class FinallyOperator<T> implements Operator<T, T> {
}

call(subscriber: Subscriber<T>, source: any): TeardownLogic {
return source.subscribe(new FinallySubscriber(subscriber, this.callback));
// The returned subscription will usually be the FinallySubscriber.
// However, interop subscribers will be wrapped and for
// unsubscriptions to chain correctly, the wrapper needs to be added, too.
const finallySubscriber = new FinallySubscriber(subscriber, this.callback);
const subscription = source.subscribe(finallySubscriber);
if (subscription !== finallySubscriber) {
subscription.add(finallySubscriber);
}
return subscription;
}
}

Expand Down

0 comments on commit aa4c11f

Please sign in to comment.