Fast renderer: an effect may change its parent element's kwargs - #66
Closed
maartenbreddels wants to merge 1 commit into
Closed
maartenbreddels wants to merge 1 commit into
maartenbreddels wants to merge 1 commit into
Conversation
Effects of child components run while the reconciler walks the kwargs of their parent widget element. When such an effect changed those kwargs (like adding a key), the fast renderer crashed with "dictionary changed size during iteration". The default renderer walks a copy of the kwargs, so it never had this problem; the fast renderer now does the same. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Closing this. Changing an element's kwargs after it was rendered (here: from a child's effect, while the parent element is being reconciled) is not something reacton should support. Elements are immutable once rendered.
We will note in |
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.
Part of the audit of
REACTON_FAST=1against the default renderer. This is one small PR per finding; this one is A2.Problem
Effects of child components run while the fast reconciler walks the kwargs of their parent widget element. If such an effect changes those kwargs (for example
parent_el.kwargs.update(box_style=...)), the fast renderer crashes withRuntimeError: dictionary changed size during iteration. The default renderer walks a copy of the kwargs (kwargs = el.kwargs.copy()at the start of_RenderContext._reconsolidate), so it does not crash.Fix
The fast renderer now walks a shallow copy too. The same copy is used for the "unchanged element" check, so that check compares against what was actually reconciled.
Tests
test_child_effect_changes_parent_element_kwargscovers the create path and the update path.REACTON_FAST=1and passes with=0. With this PR it passes in both modes.🤖 Generated with Claude Code