Skip to content

Resolve some suspense crashes#4999

Merged
JoviDeCroock merged 2 commits intov10.xfrom
find-suspense-crash
Jan 28, 2026
Merged

Resolve some suspense crashes#4999
JoviDeCroock merged 2 commits intov10.xfrom
find-suspense-crash

Conversation

@JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Jan 19, 2026

In the first commit we are resolving a suspense crash that happens when we do a state update on a component that is in a suspended state which has been unmounted.

In the second commit we resolve a forced remount of an unmounted component which resolves after unmount.

RE the second commit

Before this when we unmounted a vnode which was in a suspended state it was possible to cause this to render while being unmounted.
One disturbing thing is that I wanted to check vnode._component._onResolve in the options.unmount hook, this however was not possible because somehow the reference to _component isn't being updated on the vnode (my assumption is it being related to us cloning the vnode during the suspension) that's actually unmounting. For this reason I opted to use a separate flag.

@github-actions
Copy link

github-actions bot commented Jan 19, 2026

📊 Tachometer Benchmark Results

Summary

duration

  • create10k: unsure 🔍 -0% - +1% (-1.85ms - +5.30ms)
    preact-local vs preact-main
  • filter-list: unsure 🔍 -0% - +0% (-0.01ms - +0.06ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -3% - +2% (-1.89ms - +1.26ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - -0% (-0.08ms - -0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -1% - +1% (-0.85ms - +0.86ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -5% - +3% (-0.09ms - +0.06ms)
    preact-local vs preact-main
  • todo: unsure 🔍 -0% - +1% (-0.16ms - +0.38ms)
    preact-local vs preact-main
  • update10th1k: unsure 🔍 -4% - +3% (-1.49ms - +0.94ms)
    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.01ms)
    preact-local vs preact-main
  • hydrate1k: unsure 🔍 -2% - +11% (-0.12ms - +0.64ms)
    preact-local vs preact-main
  • many-updates: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • replace1k: unsure 🔍 -0% - +0% (-0.00ms - +0.00ms)
    preact-local vs preact-main
  • text-update: unsure 🔍 -4% - +3% (-0.04ms - +0.03ms)
    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-local874.78ms - 880.29ms-unsure 🔍
-0% - +1%
-1.85ms - +5.30ms
preact-main873.54ms - 878.08msunsure 🔍
-1% - +0%
-5.30ms - +1.85ms
-

usedJSHeapSize

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

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.56ms - 16.61ms-unsure 🔍
-0% - +0%
-0.01ms - +0.06ms
preact-main16.54ms - 16.59msunsure 🔍
-0% - +0%
-0.06ms - +0.01ms
-

usedJSHeapSize

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

duration

VersionAvg timevs preact-localvs preact-main
preact-local62.07ms - 63.99ms-unsure 🔍
-3% - +2%
-1.89ms - +1.26ms
preact-main62.09ms - 64.59msunsure 🔍
-2% - +3%
-1.26ms - +1.89ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local5.74ms - 6.32ms-unsure 🔍
-2% - +11%
-0.12ms - +0.64ms
preact-main5.53ms - 6.01msunsure 🔍
-10% - +2%
-0.64ms - +0.12ms
-
many-updates

duration

VersionAvg timevs preact-localvs preact-main
preact-local16.49ms - 16.54ms-unsure 🔍
-0% - -0%
-0.08ms - -0.00ms
preact-main16.53ms - 16.58msunsure 🔍
+0% - +0%
+0.00ms - +0.08ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.72ms - 3.72ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.72ms - 3.72msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-
replace1k
  • Browser: chrome-headless
  • Sample size: 100
  • Built by: CI #5301
  • Commit: c4514f6

duration

VersionAvg timevs preact-localvs preact-main
preact-local57.02ms - 58.21ms-unsure 🔍
-1% - +1%
-0.85ms - +0.86ms
preact-main57.00ms - 58.23msunsure 🔍
-1% - +1%
-0.86ms - +0.85ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local3.00ms - 3.00ms-unsure 🔍
-0% - +0%
-0.00ms - +0.00ms
preact-main3.00ms - 3.00msunsure 🔍
-0% - +0%
-0.00ms - +0.00ms
-

run-warmup-0

VersionAvg timevs preact-localvs preact-main
preact-local25.80ms - 26.62ms-unsure 🔍
-1% - +3%
-0.35ms - +0.80ms
preact-main25.58ms - 26.39msunsure 🔍
-3% - +1%
-0.80ms - +0.35ms
-

run-warmup-1

VersionAvg timevs preact-localvs preact-main
preact-local31.94ms - 33.21ms-unsure 🔍
-3% - +3%
-0.85ms - +0.90ms
preact-main31.95ms - 33.16msunsure 🔍
-3% - +3%
-0.90ms - +0.85ms
-

run-warmup-2

VersionAvg timevs preact-localvs preact-main
preact-local31.69ms - 32.86ms-unsure 🔍
-3% - +2%
-1.01ms - +0.68ms
preact-main31.84ms - 33.06msunsure 🔍
-2% - +3%
-0.68ms - +1.01ms
-

run-warmup-3

VersionAvg timevs preact-localvs preact-main
preact-local25.40ms - 25.81ms-unsure 🔍
-3% - +0%
-0.69ms - +0.03ms
preact-main25.64ms - 26.23msunsure 🔍
-0% - +3%
-0.03ms - +0.69ms
-

run-warmup-4

VersionAvg timevs preact-localvs preact-main
preact-local23.80ms - 25.10ms-unsure 🔍
-6% - +2%
-1.47ms - +0.46ms
preact-main24.24ms - 25.67msunsure 🔍
-2% - +6%
-0.46ms - +1.47ms
-

run-final

VersionAvg timevs preact-localvs preact-main
preact-local21.29ms - 21.81ms-unsure 🔍
-3% - +1%
-0.62ms - +0.13ms
preact-main21.52ms - 22.06msunsure 🔍
-1% - +3%
-0.13ms - +0.62ms
-
text-update
  • Browser: chrome-headless
  • Sample size: 210
  • Built by: CI #5301
  • Commit: c4514f6

duration

VersionAvg timevs preact-localvs preact-main
preact-local1.81ms - 1.92ms-unsure 🔍
-5% - +3%
-0.09ms - +0.06ms
preact-main1.83ms - 1.93msunsure 🔍
-3% - +5%
-0.06ms - +0.09ms
-

usedJSHeapSize

VersionAvg timevs preact-localvs preact-main
preact-local1.00ms - 1.04ms-unsure 🔍
-4% - +3%
-0.04ms - +0.03ms
preact-main1.00ms - 1.05msunsure 🔍
-3% - +4%
-0.03ms - +0.04ms
-
todo

duration

VersionAvg timevs preact-localvs preact-main
preact-local32.66ms - 33.14ms-unsure 🔍
-0% - +1%
-0.16ms - +0.38ms
preact-main32.67ms - 32.91msunsure 🔍
-1% - +0%
-0.38ms - +0.16ms
-

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-local33.29ms - 35.09ms-unsure 🔍
-4% - +3%
-1.49ms - +0.94ms
preact-main33.65ms - 35.29msunsure 🔍
-3% - +4%
-0.94ms - +1.49ms
-

usedJSHeapSize

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

tachometer-reporter-action v2 for CI

@github-actions
Copy link

github-actions bot commented Jan 19, 2026

Size Change: +80 B (+0.1%)

Total Size: 79.3 kB

Filename Size Change
compat/dist/compat.js 4.2 kB +19 B (+0.45%)
compat/dist/compat.mjs 4.13 kB +21 B (+0.51%)
compat/dist/compat.module.js 4.13 kB +21 B (+0.51%)
compat/dist/compat.umd.js 4.27 kB +19 B (+0.45%)
ℹ️ View Unchanged
Filename Size
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 260 B
devtools/dist/devtools.mjs 274 B
devtools/dist/devtools.module.js 274 B
devtools/dist/devtools.umd.js 346 B
dist/preact.js 4.78 kB
dist/preact.min.js 4.8 kB
dist/preact.min.module.js 4.8 kB
dist/preact.min.umd.js 4.82 kB
dist/preact.mjs 4.79 kB
dist/preact.module.js 4.79 kB
dist/preact.umd.js 4.83 kB
hooks/dist/hooks.js 1.54 kB
hooks/dist/hooks.mjs 1.57 kB
hooks/dist/hooks.module.js 1.57 kB
hooks/dist/hooks.umd.js 1.61 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

});
});

it('should not crash when suspended child updates after unmount', () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncommenting line 240 will surface the crash of this

Before this when we unmounted a vnode which was in a suspended state
it was possible to cause this to render while being unmounted.
One disturbing thing is that I wanted to check
vnode._component._onResolve
in the options.unmount hook, this however was not possible because
somehow the reference to `_component` isn't being updated on the
vnode that's actually unmounting. For this reason I opted to
use a separate flag.
Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

} from 'preact/compat';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { createLazy, createSuspender } from './suspense-utils';
import { expect } from 'chai';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe nit: is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whups, darn vscode auto-import

@JoviDeCroock JoviDeCroock merged commit 2ac91c4 into v10.x Jan 28, 2026
12 checks passed
@JoviDeCroock JoviDeCroock deleted the find-suspense-crash branch January 28, 2026 17:35
@JoviDeCroock JoviDeCroock mentioned this pull request Jan 31, 2026
JoviDeCroock added a commit that referenced this pull request Jan 31, 2026
* Fix suspense crash

* Prevent unmounted suspended vnodes from rendering

Before this when we unmounted a vnode which was in a suspended state
it was possible to cause this to render while being unmounted.
One disturbing thing is that I wanted to check
vnode._component._onResolve
in the options.unmount hook, this however was not possible because
somehow the reference to `_component` isn't being updated on the
vnode that's actually unmounting. For this reason I opted to
use a separate flag.
@JoviDeCroock JoviDeCroock mentioned this pull request Feb 1, 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.

3 participants