Skip to content

Fix hydrate recovery with null excess DOM children - #5112

Merged
JoviDeCroock merged 1 commit into
v10.xfrom
fix-hydration-null-excess-dom-children
Jun 10, 2026
Merged

Fix hydrate recovery with null excess DOM children#5112
JoviDeCroock merged 1 commit into
v10.xfrom
fix-hydration-null-excess-dom-children

Conversation

@JoviDeCroock

Copy link
Copy Markdown
Member

summary

Avoid hydration recovery crashes when a suspending or throwing component is diffed with no excess DOM children.

Solution

Guard excessDomChildren access in diff() and add hydration regression coverage.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -1% - +0% (-5.78ms - +1.33ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - -0% (-0.07ms - -0.00ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +3% (-0.95ms - +1.75ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -2% - +2% (-0.33ms - +0.40ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +0% (-0.82ms - +0.13ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -5% - +3% (-0.10ms - +0.06ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -2% - +3% (-0.78ms - +0.95ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -4% - +3% (-1.30ms - +0.90ms)
    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 🔍 -2% - +5% (-0.10ms - +0.25ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.01ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.01ms - +0.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -0% - +7% (-0.00ms - +0.07ms)
    preact-local vs preact-main
  • todo: unsure 🔍 +0% - +0% (+0.00ms - +0.00ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -0% - +0% (-0.01ms - +0.01ms)
    preact-local vs preact-main

Results

create10k

duration

VersionAvg timevs preact-localvs preact-main
preact-local756.30ms - 760.85ms-unsure 🔍
-1% - +0%
-5.78ms - +1.33ms
preact-main758.07ms - 763.53msunsure 🔍
-0% - +1%
-1.33ms - +5.78ms
-

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.58ms-unsure 🔍
-0% - -0%
-0.07ms - -0.00ms
preact-main16.57ms - 16.60msunsure 🔍
+0% - +0%
+0.00ms - +0.07ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.56ms - 1.56ms-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-local58.81ms - 60.63ms-unsure 🔍
-2% - +3%
-0.95ms - +1.75ms
preact-main58.33ms - 60.32msunsure 🔍
-3% - +2%
-1.75ms - +0.95ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local4.97ms - 5.29ms-unsure 🔍
-2% - +5%
-0.10ms - +0.25ms
preact-main4.99ms - 5.13msunsure 🔍
-5% - +2%
-0.25ms - +0.10ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local15.99ms - 16.56ms-unsure 🔍
-2% - +2%
-0.33ms - +0.40ms
preact-main16.01ms - 16.46msunsure 🔍
-2% - +2%
-0.40ms - +0.33ms
-

usedJSHeapSize

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

duration

VersionAvg timevs preact-localvs preact-main
preact-local55.83ms - 56.49ms-unsure 🔍
-1% - +0%
-0.82ms - +0.13ms
preact-main56.16ms - 56.84msunsure 🔍
-0% - +1%
-0.13ms - +0.82ms
-

usedJSHeapSize

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

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local25.71ms - 26.44ms-unsure 🔍
-2% - +1%
-0.63ms - +0.38ms
preact-main25.85ms - 26.54msunsure 🔍
-1% - +2%
-0.38ms - +0.63ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local29.16ms - 29.98ms-unsure 🔍
-1% - +2%
-0.39ms - +0.68ms
preact-main29.09ms - 29.77msunsure 🔍
-2% - +1%
-0.68ms - +0.39ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local29.12ms - 30.24ms-unsure 🔍
-4% - +1%
-1.17ms - +0.39ms
preact-main29.53ms - 30.61msunsure 🔍
-1% - +4%
-0.39ms - +1.17ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local24.12ms - 24.44ms-faster ✔
1% - 3%
0.15ms - 0.63ms
preact-main24.49ms - 24.85msslower ❌
1% - 3%
0.15ms - 0.63ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local22.37ms - 23.29ms-unsure 🔍
-5% - +1%
-1.12ms - +0.33ms
preact-main22.67ms - 23.79msunsure 🔍
-1% - +5%
-0.33ms - +1.12ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local19.83ms - 20.11ms-unsure 🔍
-2% - +0%
-0.40ms - +0.03ms
preact-main19.99ms - 20.32msunsure 🔍
-0% - +2%
-0.03ms - +0.40ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 230
  • Built by: CI #5558
  • Commit: 4526da0

duration

VersionAvg timevs preact-localvs preact-main
preact-local2.03ms - 2.15ms-unsure 🔍
-5% - +3%
-0.10ms - +0.06ms
preact-main2.05ms - 2.16msunsure 🔍
-3% - +5%
-0.06ms - +0.10ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.04ms - 1.10ms-unsure 🔍
-0% - +7%
-0.00ms - +0.07ms
preact-main1.02ms - 1.06msunsure 🔍
-6% - +0%
-0.07ms - +0.00ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local35.60ms - 37.16ms-unsure 🔍
-2% - +3%
-0.78ms - +0.95ms
preact-main35.92ms - 36.66msunsure 🔍
-3% - +2%
-0.95ms - +0.78ms
-

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-local29.07ms - 30.47ms-unsure 🔍
-4% - +3%
-1.30ms - +0.90ms
preact-main29.12ms - 30.82msunsure 🔍
-3% - +4%
-0.90ms - +1.30ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local2.98ms - 2.99ms-unsure 🔍
-0% - +0%
-0.01ms - +0.01ms
preact-main2.98ms - 2.99msunsure 🔍
-0% - +0%
-0.01ms - +0.01ms
-

tachometer-reporter-action v2 for CI

@github-actions

Copy link
Copy Markdown

Size Change: +40 B (+0.05%)

Total Size: 79.3 kB

📦 View Changed
Filename Size Change
dist/preact.js 4.79 kB +6 B (+0.13%)
dist/preact.min.js 4.81 kB +5 B (+0.1%)
dist/preact.min.module.js 4.82 kB +6 B (+0.12%)
dist/preact.min.umd.js 4.83 kB +5 B (+0.1%)
dist/preact.mjs 4.82 kB +7 B (+0.15%)
dist/preact.module.js 4.82 kB +7 B (+0.15%)
dist/preact.umd.js 4.84 kB +4 B (+0.08%)
ℹ️ 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.52 kB
hooks/dist/hooks.mjs 1.56 kB
hooks/dist/hooks.module.js 1.56 kB
hooks/dist/hooks.umd.js 1.59 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 merged commit 82ed24e into v10.x Jun 10, 2026
12 checks passed
@JoviDeCroock
JoviDeCroock deleted the fix-hydration-null-excess-dom-children branch June 10, 2026 16:53
@JoviDeCroock JoviDeCroock mentioned this pull request Jun 25, 2026
JoviDeCroock added a commit that referenced this pull request Jun 25, 2026
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