fix(runtime): keep isQueuedForUpdate guard active under taskQueue: 'immediate'#6788
Open
erlanzhou wants to merge 1 commit into
Open
fix(runtime): keep isQueuedForUpdate guard active under taskQueue: 'immediate'#6788erlanzhou wants to merge 1 commit into
erlanzhou wants to merge 1 commit into
Conversation
…mmediate' Both the set (scheduleUpdate) and clear (callRender) of HOST_FLAGS.isQueuedForUpdate were gated on BUILD.taskQueue, so under taskQueue: 'immediate' the render reentrancy guard was inert. Because immediate dispatches synchronously, a state write during render() (e.g. measure-then-setState) re-entered the render unbounded and could corrupt an in-flight vdom patch. Gate the flag on BUILD.updatable only; async/congestionAsync behavior is unchanged. Complements stenciljs#6673.
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.
What is the current behavior?
GitHub Issue Number: #6787
Under
taskQueue: 'immediate'theHOST_FLAGS.isQueuedForUpdatereentrancy/dedup guard is inert: both its set (scheduleUpdate) and clear (callRender) were gated behindBUILD.taskQueue, which isfalsein immediate mode. Since immediate dispatches renders synchronously, a state write duringrender()(e.g. measure DOM then set state for the final DOM for text middle truncation) synchronously re-enters the render — unbounded, and able to corrupt an in-flight vdom patch (Cannot read properties of null (reading 'nodeType')).#6673 patched one entry point (reflected bool attr removal); this further addresses the root cause.
What is the new behavior?
The set/clear of
isQueuedForUpdateis now gated onBUILD.updatableonly. The flag correctly reflects "an update is scheduled/in-progress" in every scheduling mode, sosetValue/forceUpdatecoalesce a state write made during render instead of re-entering.async/congestionAsync: no behavior change (BUILD.taskQueueistrue, so both conditions evaluate the same as before).immediate: renders stay synchronous for external updates, but an in-render write no longer causes a synchronous reentrant re-render.Documentation
Does this introduce a breaking change?
Immediate mode still dispatches renders synchronously; only removed the unbounded re-entry.
Testing
src/runtime/test/immediate-reentrancy.spec.tsxasserts that one external update produces exactly one follow-up render in bothasyncandimmediate(drives the real runtime withBUILD.taskQueuetoggled). Fails before the fix (unbounded), passes after.npx jest src/runtime— 651 tests / 64 suites green.Other information