Skip to content

Commit

Permalink
Forget cache entry for maybeBroadcastWatch when unwatching.
Browse files Browse the repository at this point in the history
Inspired by @kamilkisiela's comment:
#7149 (comment)

Should fix #7149 and #7086.
  • Loading branch information
benjamn committed Oct 13, 2020
1 parent e8f419e commit 6a2f326
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
}
return () => {
this.watches.delete(watch);
this.watchDep.dirty(watch);
// Remove this watch from the LRU cache managed by the
// maybeBroadcastWatch OptimisticWrapperFunction, to prevent memory
// leaks involving the closure of watch.callback.
this.maybeBroadcastWatch.forget(watch);
};
}

Expand Down

0 comments on commit 6a2f326

Please sign in to comment.