Fix _get_all_hooks_internal mutating the shared per-node hooks cache#6741
Open
Alek99 wants to merge 2 commits into
Open
Fix _get_all_hooks_internal mutating the shared per-node hooks cache#6741Alek99 wants to merge 2 commits into
Alek99 wants to merge 2 commits into
Conversation
_get_all_hooks_internal called .update() directly on the dict returned by _get_hooks_internal, which is the node's cached _hooks_internal_cache. Walking a tree therefore polluted every node's cache with its descendants' hooks, making hook collection order-dependent: memo tag hashes over internal hooks could differ for identical subtrees (defeating dedup) and per-node hook queries returned descendant hooks. Copy the cached dict before merging children's hooks into it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G8cXh3TUbNtbjm2ERqE62X
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G8cXh3TUbNtbjm2ERqE62X
Merging this PR will not alter performance
Comparing Footnotes
|
Contributor
Greptile SummaryThis PR fixes internal hook collection so subtree hooks no longer mutate per-node caches.
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "Add changelog fragment" | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linear: ENG-10108
Description
Component._get_all_hooks_internalcalled.update()directly on the dict returned by_get_hooks_internal(), which is the node's cached_hooks_internal_cache. Collecting hooks for a subtree therefore permanently polluted every intermediate node's cache with its descendants' hooks. The same cached dict was further mutated through|=inBare._get_all_hooks_internal.Consequences of the pollution:
_update_deterministic_hash) could differ for otherwise-identical subtrees, defeating memo dedup._get_hooks_internal) returned descendants' hooks, duplicating hooks into memo bodies and skewing subtree reactivity classification.Fix: copy the cached dict before merging children's hooks into it.
Bare's|=then mutates the fresh copy returned bysuper(), so it needs no change.Type of change
Changes To Core Features:
tests/units/components/test_component.py::test_get_all_hooks_internal_does_not_mutate_hooks_cache: asserts subtree collection includes both nodes' hooks while each node's own cache stays unpolluted, and that repeated collection is stable. Fails before this fix.🤖 Generated with Claude Code
https://claude.ai/code/session_01G8cXh3TUbNtbjm2ERqE62X
Generated by Claude Code