Skip to content

Commit

Permalink
Don't emit values from disposable observable if instance is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Feb 22, 2025
1 parent 125d324 commit a8e2093
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,13 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`,
this.linkObservable = observable;
this.linkSubscription = observable.subscribe(observer);
} else {
observable.subscribe(observer);
// When using a disposable observable, its possible it may continue to
// emit values after the observable query has been closed since we don't
// track its subscription. We don't want to try and emit any more values
// on this instance otherwise RxJS will throw an error trying to emit a
// value on a closed subject so we filter out all messages after this
// instance is closed.
observable.pipe(filter(() => !this.closed)).subscribe(observer);
}

return preventUnhandledRejection(
Expand Down

0 comments on commit a8e2093

Please sign in to comment.