Skip to content

Fix error recovery for partially rendered subtrees - #5120

Merged
JoviDeCroock merged 1 commit into
v10.xfrom
account-for-attribute-setting-errors
Jun 25, 2026
Merged

JoviDeCroock merged 1 commit into
v10.xfrom
account-for-attribute-setting-errors

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member

When a component throws after diffChildren() has already started, its newVNode._children may contain partially mounted children. The error recovery path always replaced those children with oldVNode._children, which can be undefined during initial mount.

That loses the partially rendered subtree, so children that queued updates are not unmounted and keep their _parentDom. A later queued update can then call getDomSibling() through an ancestor whose _children is undefined and crash.

Only restore old children when the new vnode has no children yet, and discard commit/ref queue entries produced by the failed partial render so lifecycles from the aborted subtree are not committed.

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-1.56ms - +5.70ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.04ms - +0.06ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +3% (-1.49ms - +1.86ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -3% - +2% (-0.48ms - +0.26ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -2% - +1% (-1.19ms - +0.30ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -2% - +6% (-0.05ms - +0.12ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -1% - +2% (-0.30ms - +0.48ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -1% - +5% (-0.44ms - +1.57ms)
    preact-local vs preact-main

usedJSHeapSize

  • create10k: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -4% - +2% (-0.19ms - +0.12ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 +0% - +0% (+0.00ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -3% - +3% (-0.03ms - +0.04ms)
    preact-local vs preact-main
  • todo: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local825.55ms - 830.76ms-unsure 🔍
-0% - +1%
-1.56ms - +5.70ms
preact-main823.55ms - 828.61msunsure 🔍
-1% - +0%
-5.70ms - +1.56ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local19.21ms - 19.21ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main19.21ms - 19.21msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
filter-list

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.52ms - 16.61ms-unsure 🔍
-0% - +0%
-0.04ms - +0.06ms
preact-main16.53ms - 16.57msunsure 🔍
-0% - +0%
-0.06ms - +0.04ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.56ms - 1.57ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main1.56ms - 1.56msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
hydrate1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local63.20ms - 65.88ms-unsure 🔍
-2% - +3%
-1.49ms - +1.86ms
preact-main63.35ms - 65.36msunsure 🔍
-3% - +2%
-1.86ms - +1.49ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local5.00ms - 5.20ms-unsure 🔍
-4% - +2%
-0.19ms - +0.12ms
preact-main5.01ms - 5.25msunsure 🔍
-2% - +4%
-0.12ms - +0.19ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.35ms - 16.51ms-unsure 🔍
-3% - +2%
-0.48ms - +0.26ms
preact-main16.18ms - 16.90msunsure 🔍
-2% - +3%
-0.26ms - +0.48ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.73ms - 3.74ms-unsure 🔍
+0% - +0%
+0.00ms - +0.01ms
preact-main3.73ms - 3.73msunsure 🔍
-0% - -0%
-0.01ms - -0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #5577
  • Commit: cea8dba

duration

VersionAvg timevs preact-localvs preact-main
preact-local58.01ms - 59.12ms-unsure 🔍
-2% - +1%
-1.19ms - +0.30ms
preact-main58.51ms - 59.51msunsure 🔍
-1% - +2%
-0.30ms - +1.19ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.02ms - 3.02ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.01ms - 3.02msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local28.11ms - 29.08ms-unsure 🔍
-3% - +2%
-0.75ms - +0.52ms
preact-main28.30ms - 29.13msunsure 🔍
-2% - +3%
-0.52ms - +0.75ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local32.87ms - 33.86ms-unsure 🔍
-1% - +3%
-0.21ms - +1.11ms
preact-main32.48ms - 33.36msunsure 🔍
-3% - +1%
-1.11ms - +0.21ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local32.95ms - 34.10ms-unsure 🔍
-0% - +5%
-0.11ms - +1.51ms
preact-main32.26ms - 33.39msunsure 🔍
-4% - +0%
-1.51ms - +0.11ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local26.99ms - 27.45ms-unsure 🔍
-0% - +2%
-0.06ms - +0.58ms
preact-main26.74ms - 27.18msunsure 🔍
-2% - +0%
-0.58ms - +0.06ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local22.66ms - 23.68ms-unsure 🔍
-4% - +2%
-1.01ms - +0.47ms
preact-main22.90ms - 23.97msunsure 🔍
-2% - +4%
-0.47ms - +1.01ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local21.56ms - 21.92ms-unsure 🔍
-2% - +1%
-0.39ms - +0.12ms
preact-main21.69ms - 22.05msunsure 🔍
-1% - +2%
-0.12ms - +0.39ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 230
  • Built by: CI #5577
  • Commit: cea8dba

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.04ms - 2.15ms-unsure 🔍
-2% - +6%
-0.05ms - +0.12ms
preact-main2.00ms - 2.12msunsure 🔍
-6% - +2%
-0.12ms - +0.05ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.03ms - 1.08ms-unsure 🔍
-3% - +3%
-0.03ms - +0.04ms
preact-main1.03ms - 1.08msunsure 🔍
-3% - +3%
-0.04ms - +0.03ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local24.96ms - 25.49ms-unsure 🔍
-1% - +2%
-0.30ms - +0.48ms
preact-main24.85ms - 25.42msunsure 🔍
-2% - +1%
-0.48ms - +0.30ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.26ms - 1.26ms-unsure 🔍
+0% - +0%
+0.00ms - +0.00ms
preact-main1.26ms - 1.26msunsure 🔍
-0% - -0%
-0.00ms - -0.00ms
-
update10th1k

duration

VersionAvg timevs preact-localvs preact-main
preact-local32.41ms - 33.88ms-unsure 🔍
-1% - +5%
-0.44ms - +1.57ms
preact-main31.89ms - 33.26msunsure 🔍
-5% - +1%
-1.57ms - +0.44ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.99ms - 3.00ms-unsure 🔍
-0% - +0%
-0.00ms - +0.01ms
preact-main2.99ms - 3.00msunsure 🔍
-0% - +0%
-0.01ms - +0.00ms
-

tachometer-reporter-action v2 for CI

@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Size Change: +205 B (+0.26%)

Total Size: 79.5 kB

📦 View Changed
Filename Size Change
dist/preact.js 4.83 kB +30 B (+0.62%)
dist/preact.min.js 4.85 kB +28 B (+0.58%)
dist/preact.min.module.js 4.86 kB +29 B (+0.6%)
dist/preact.min.umd.js 4.87 kB +28 B (+0.58%)
dist/preact.mjs 4.86 kB +30 B (+0.62%)
dist/preact.module.js 4.86 kB +30 B (+0.62%)
dist/preact.umd.js 4.88 kB +30 B (+0.62%)
ℹ️ View Unchanged
Filename Size
compat/dist/compat.js 4.19 kB
compat/dist/compat.mjs 4.11 kB
compat/dist/compat.module.js 4.11 kB
compat/dist/compat.umd.js 4.25 kB
debug/dist/debug.js 3.85 kB
debug/dist/debug.mjs 3.85 kB
debug/dist/debug.module.js 3.85 kB
debug/dist/debug.umd.js 3.93 kB
devtools/dist/devtools.js 259 B
devtools/dist/devtools.mjs 274 B
devtools/dist/devtools.module.js 274 B
devtools/dist/devtools.umd.js 345 B
hooks/dist/hooks.js 1.51 kB
hooks/dist/hooks.mjs 1.54 kB
hooks/dist/hooks.module.js 1.54 kB
hooks/dist/hooks.umd.js 1.58 kB
jsx-runtime/dist/jsxRuntime.js 1.01 kB
jsx-runtime/dist/jsxRuntime.mjs 985 B
jsx-runtime/dist/jsxRuntime.module.js 985 B
jsx-runtime/dist/jsxRuntime.umd.js 1.08 kB
test-utils/dist/testUtils.js 473 B
test-utils/dist/testUtils.mjs 477 B
test-utils/dist/testUtils.module.js 477 B
test-utils/dist/testUtils.umd.js 555 B

compressed-size-action

@JoviDeCroock
JoviDeCroock force-pushed the account-for-attribute-setting-errors branch 2 times, most recently from 9a95f7c to 67dc28d Compare June 25, 2026 05:45
When a component throws after `diffChildren()` has already started, its
`newVNode._children` may contain partially mounted children. The error recovery
path always replaced those children with `oldVNode._children`, which can be
`undefined` during initial mount.

That loses the partially rendered subtree, so children that queued updates are
not unmounted and keep their _parentDom. A later queued update can then call
`getDomSibling()` through an ancestor whose `_children` is undefined and crash.

Only restore old children when the new vnode has no children yet, and discard
commit/ref queue entries produced by the failed partial render so lifecycles from
the aborted subtree are not committed.
@JoviDeCroock
JoviDeCroock force-pushed the account-for-attribute-setting-errors branch from 67dc28d to cea8dba Compare June 25, 2026 05:47
@JoviDeCroock
JoviDeCroock merged commit 1a3b8b5 into v10.x Jun 25, 2026
12 checks passed
@JoviDeCroock
JoviDeCroock deleted the account-for-attribute-setting-errors branch June 25, 2026 14:26
@JoviDeCroock JoviDeCroock mentioned this pull request Jun 25, 2026
JoviDeCroock added a commit that referenced this pull request Jun 25, 2026
When a component throws after `diffChildren()` has already started, its
`newVNode._children` may contain partially mounted children. The error recovery
path always replaced those children with `oldVNode._children`, which can be
`undefined` during initial mount.

That loses the partially rendered subtree, so children that queued updates are
not unmounted and keep their _parentDom. A later queued update can then call
`getDomSibling()` through an ancestor whose `_children` is undefined and crash.

Only restore old children when the new vnode has no children yet, and discard
commit/ref queue entries produced by the failed partial render so lifecycles from
the aborted subtree are not committed.

(cherry picked from commit 1a3b8b5)
JoviDeCroock added a commit that referenced this pull request Jun 26, 2026
* Fix hydrate error recovery with null excess DOM children (#5112)

(cherry picked from commit 82ed24e)

* perf(hooks): avoid redundant allocations and writes in SCU and diffed (#5115)

(cherry picked from commit 6aced21)

* Fix memory leak hotspots (#5116)

- render: clear the root Fragment's props.children after commit so replaced vnode generations are not retained

- unmount: clear component._globalContext with the other component references

(cherry picked from commit bd0302d)

* Flush subtree effects (#5055)

(cherry picked from commit d9e8984)

* Fix useId stability across async Suspense (#5108)

Assisted-By: devx/1b997072-d89c-4f6a-a18f-9525b3ef7a9e
(cherry picked from commit 67f0290)

* Fix error recovery for partially rendered subtrees (#5120)

When a component throws after `diffChildren()` has already started, its
`newVNode._children` may contain partially mounted children. The error recovery
path always replaced those children with `oldVNode._children`, which can be
`undefined` during initial mount.

That loses the partially rendered subtree, so children that queued updates are
not unmounted and keep their _parentDom. A later queued update can then call
`getDomSibling()` through an ancestor whose `_children` is undefined and crash.

Only restore old children when the new vnode has no children yet, and discard
commit/ref queue entries produced by the failed partial render so lifecycles from
the aborted subtree are not committed.

(cherry picked from commit 1a3b8b5)
@JoviDeCroock JoviDeCroock mentioned this pull request Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants