Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to clean context during tearDownQuery #7276

Merged
merged 2 commits into from
Nov 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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