Abort render when state setter is called during render#64
Merged
Conversation
…to 2.3.1 Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix abort render when re-render is requested during render
Abort render when state setter is called during render
Mar 4, 2026
L3P3
requested changes
Mar 4, 2026
…est counter Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an early-abort optimization to stop executing the remainder of a component render when a state/model setter schedules a rerender during that same render pass, reusing the existing dom_cache sentinel and relying on instance.dirty to distinguish abort types.
Changes:
- Throw
dom_cachefromhook_state/hook_modelsetters when invoked during the owning component’s render, to abort wasted work. - In
instance_render, return early on catching the sentinel wheninstance.dirtyindicates a rerender has already been queued. - Adjust
hook_sub/hook_mapto propagate the abort sentinel upward instead of swallowing it; bump version to2.3.1; add a test forhook_stateabort behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/lui.js |
Implements the render-abort mechanism across instance_render, hook_state, hook_model, hook_sub, and hook_map. |
test/hook-state.test.js |
Adds a regression test for abort + immediate rerender when a state setter is called during render. |
package.json |
Bumps patch version 2.3.0 → 2.3.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: L3P3 <4629449+L3P3@users.noreply.github.com>
L3P3
approved these changes
Mar 4, 2026
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.
hook_statesetter: throwdom_cachewhen state is set during rendering of the same componenthook_modelmutation setters: same throw logicinstance_rendercatch block: detect the abort (instance.dirty=true) and return early (bail out)hook_subcatch block: rethrowdom_cachewhen instance is dirty (propagate abort upward)hook_mapcatch block: rethrowdom_cachewhen instance is dirty (propagate abort upward)ifblocks inhook_subandhook_mapcatch blocks using trailing||ifconditions in 3-line style inhook_stateandhook_modelsettersafter_set_countcounter to verify code past the setter only runs onceOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.