Skip to content

Commit

Permalink
Make sure to clean options.context during ObservableQuery#tearDownQue…
Browse files Browse the repository at this point in the history
…ry (#7276)
  • Loading branch information
dotansimha committed Nov 20, 2020
1 parent 75d854f commit 3e58873
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,22 +627,25 @@ once, rather than every time you call fetchMore.`);
private tearDownQuery() {
if (this.isTornDown) return;

const { queryManager } = this;

if (this.reobserver) {
this.reobserver.stop();
delete this.reobserver;
}

this.isTornDown = true;
// Since the user-provided context object can retain arbitrarily large
// amounts of memory, we delete it when the ObservableQuery is torn
// down, to avoid the possibility of memory leaks.
delete this.options.context;

// stop all active GraphQL subscriptions
this.subscriptions.forEach(sub => sub.unsubscribe());
this.subscriptions.clear();

queryManager.stopQuery(this.queryId);
this.queryManager.stopQuery(this.queryId);

this.observers.clear();

this.isTornDown = true;
}
}

Expand Down

0 comments on commit 3e58873

Please sign in to comment.