Skip to content

Commit

Permalink
A few tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Nov 20, 2020
1 parent 005b357 commit c079085
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/core/ObservableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -625,23 +625,27 @@ once, rather than every time you call fetchMore.`);
}

private tearDownQuery() {
const { queryManager } = this;
if (this.isTornDown) return;

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

this.isTornDown = true;
this.options.context = undefined;
// 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 c079085

Please sign in to comment.