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 Jan 17, 2020
1 parent 4aeafe1 commit b92d1db
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 @@ -69,7 +69,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 b92d1db

Please sign in to comment.