Fast renderer: clean up removed components before new effects run - #68
Merged
Merged
Conversation
When a component replaces another one in a container, the default renderer runs the effect cleanups of the removed component before the effects of the new one. The fast renderer removed stale elements only after the whole context was reconciled, so the new effect ran first. An effect that sets a global value and resets it in its cleanup then ended with the reset value, and with two failing cleanups a different exception reached use_exception. The fast renderer now runs the effect cleanups of stale components at the same point as the default renderer. Their widgets are still closed later, after the parent got its new children, as before. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Review found that taking stale keys from the front of a list is quadratic in the number of stale keys, that a closed context kept the removed keys alive through its new bookkeeping fields, and that the cleanup loop left self.context changed. The fuzz test only logged effect runs, so it could not see a difference in cleanup order: with cleanups logged, 7 of its 12 cases fail on master and all pass with this change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
maartenbreddels
force-pushed
the
fix/fast-cleanup-before-new-effects
branch
from
September 29, 2026 09:33
e4b9314 to
f474df4
Compare
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 D5.Problem
When a component replaces another one in a container (a conditional child, or a changed key), the default renderer runs the effect cleanups of the removed component before the effects of the new one. The fast renderer removed stale elements only after it had reconciled the whole context, so the new effect ran first. Two things went wrong:
None) in fast mode, but with the new value in default mode.use_exception.Fix
benchmarks/README.md).ComponentContextfields.Tests
core_test.py. Both fail on master withREACTON_FAST=1and pass in both modes.fuzz_test.pynow also logs effect cleanups. Before, it compared effect runs only, so it could not see this class of bug. With cleanups logged, 7 of its 12 cases fail on master; with this PR all 12 pass. A reviewer's extended fuzz run found 0 of 400 seeds that differ, against 217 on master.Review
Crossreview with Astra (GPT-6), Opus and GLM, in 2 rounds. All three approve the final version.
pop(0)made the cleanup quadratic;self.contextwas not restored;.shared()elements are still broken in both renderers, as they are on master. That needs its own issue.The fix was written by a codex worker and reviewed and adjusted by me.
🤖 Generated with Claude Code