Skip to content

Commit 11b547c

Browse files
committed
Avoid calling forgetChildren in entry.setDirty, but call it in .dispose.
apollographql/apollo-client#8147 (comment)
1 parent e3ab93b commit 11b547c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/entry.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export class Entry<TArgs extends any[], TValue> {
9797
this.dirty = true;
9898
this.value.length = 0;
9999
reportDirty(this);
100-
forgetChildren(this);
101100
// We can go ahead and unsubscribe here, since any further dirty
102101
// notifications we receive will be redundant, and unsubscribing may
103102
// free up some resources, e.g. file watchers.
@@ -107,6 +106,11 @@ export class Entry<TArgs extends any[], TValue> {
107106
public dispose() {
108107
this.setDirty();
109108

109+
// Sever any dependency relationships with our own children, so those
110+
// children don't retain this parent Entry in their child.parents sets,
111+
// thereby preventing it from being fully garbage collected.
112+
forgetChildren(this);
113+
110114
// Because this entry has been kicked out of the cache (in index.js),
111115
// we've lost the ability to find out if/when this entry becomes dirty,
112116
// whether that happens through a subscription, because of a direct call

0 commit comments

Comments
 (0)