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

Reactivate reactive variables when InMemoryCache acquires first watcher. #7657

Merged
merged 3 commits into from
Feb 5, 2021

Conversation

benjamn
Copy link
Member

@benjamn benjamn commented Feb 4, 2021

Fixes a bug introduced by #7279, which was triggered by calling this.cancel() before re-watching in the QueryInfo#updateWatch method, causing cache.watches.size to drop to zero temporarily, thereby invoking forgetCache(cache). When this happened, reactive variables would stop broadcasting updates to the forgotten cache, even though the unwatching was only momentary, and would not begin broadcasting again until the association was reestablished by other means.

This new implementation uses a WeakMap to remember associations between caches and sets of reactive variables, which makes it possible to recall those associations later, provided the cache has not been garbage collected in the meantime.

Should fix #7593 and #7630, though #7622 remains a concern.

Fixes a bug introduced by #7279, which was triggered by calling
this.cancel() before re-watching in the QueryInfo#updateWatch method,
causing cache.watches.size to drop to zero temporarily, thereby invoking
forgetCache(cache). When this happened, reactive variables would stop
broadcasting updates to the forgotten cache, even though the unwatching
was only momentary, and would not begin broadcasting again until the
association was reestablished by other means.

This new implementation uses a WeakMap to remember the association between
caches and sets of reactive variables, which makes it possible to recall
those associations later, provided the cache has not been garbage
collected in the meantime.
@benjamn benjamn changed the title Reactivate reactive variables when InMemoryCache gets new watchers. Reactivate reactive variables when InMemoryCache acquires first watcher. Feb 4, 2021
@benjamn benjamn force-pushed the reactivate-reactive-variables branch from c2e50a9 to 8b248ab Compare February 4, 2021 23:38
Copy link
Member

@hwillson hwillson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @benjamn! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants