ISSUE DESCRIPTION Teleport + Suspense: unmount crashes on pending teleport with…
- User
ISSUE DESCRIPTION
Teleport + Suspense: unmount crashes on pending teleport with component child (regression since 3.5.31)
Vue version
3.5.34
Link to minimal reproduction
https://github.com/pont1s/vue-teleport-unmount-crashes
Steps to reproduce
Option 1 — Browser (primary)
pnpm dev- Open the browser DevTools console.
- Click "Unmount Suspense".
- Observe
TypeError: Cannot read properties of null (reading 'type')in the console
Option 2 — Tests (additional)
pnpm testThe repo also contains three Vitest tests in
tests/teleport-unmount.test.jsWhat is expected?
When a inside a is unmounted before its mount can run, Vue should remove it cleanly. This worked correctly in 3.5.30.
What is actually happening?
In 3.5.31..3.5.34, unmounting such a teleport throws:
TypeError: Cannot read properties of null (reading 'type') at unmountComponent (runtime-core.cjs.js) at unmount at Object.remove (TeleportImpl.remove) at unmount at unmountChildren at unmount at unmountComponent at unmount at Object.resolve (Suspense)System Info
System: OS: macOS 26.3.1 CPU: (8) arm64 Apple M1 Memory: 102.19 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.15.0 - /Users/user/.local/state/fnm_multishells/14407_1779493498078/bin/node npm: 11.12.1 - /Users/user/.local/state/fnm_multishells/14407_1779493498078/bin/npm pnpm: 11.1.3 - /Users/user/.local/state/fnm_multishells/14407_1779493498078/bin/pnpm Browsers: Chrome: 148.0.7778.179 Safari: 26.3.1 npmPackages: vue: 3.5.34 => 3.5.34Any additional comments?
This is a continuation of the regression chain that started in 3.5.31:
- PR #8619 (3.5.31) introduced
pendingMountsso teleports defer their mount whenparentSuspense.pendingBranchis set. This is what created the situation where a teleport's children can havevnode.component === null. - Issue #14640 + (3.5.32) added the check shown above. That gates DOM removal of children, not the call on children.
Assistant
I'll start by exploring the repository structure to understand the codebase and then reproduce the issue.
Assistant
Let me make single calls.
Assistant
Let me explore the structure more, particularly the teleport-related files.
Assistant
Let me look at the
removemethod more closely.Assistant
Now let me look at the
unmountandunmountComponentfunctions in the renderer.Assistant
Let me look at the
queuePostRenderEffectand how the Suspense handles pending effects.Assistant
Let me look at the Suspense's unmount method.
Assistant
Let me look at existing tests for teleport + suspense to understand the test patterns.
Assistant
Let me check the test helpers and setup.
Assistant
Let me create a reproduction test to confirm the issue.
Assistant
The test renderer doesn't support querySelector. Let me rewrite the reproduction using the DOM renderer with jsdom, following the existing test pattern.
Assistant
I've reproduced the exact error from the issue. The stack trace matches:
TypeError: Cannot read properties of null (reading 'type') at unmountComponent (renderer.ts:2317) at unmount at Object.remove (Teleport.ts:355) at unmount at unmountChildren at unmount at Object.unmount (Suspense.ts:791)Now let me examine the
removemethod and apply the fix. The bug is clear: whenpendingMountis set (mount job hasn't run, so children were never mounted), the code still callsunmounton the children. For element childrenshouldRemove=falseprevents DOM removal, but for component childrenunmountstill callsunmountComponent(vnode.component!, ...)wherevnode.componentisnull, causing the crash.Let me view the exact lines to edit:
Assistant
Let me use the edit command directly.
Assistant
No python. Let me use node instead.
Assistant
Let me verify the change.
Assistant
Now let me run the reproduction test again to confirm the fix.
Assistant
The fix works. Now let me test some edge cases. Let me expand the reproduction test to cover more scenarios: disabled teleport, element children, mixed children, and the case where suspense resolves normally.
Assistant
The last test failure is about the normal (resolved) path, not the pending path, so it's likely a test setup issue. Let me debug it.
Assistant
The debug test works — the issue in my failing test was that
AsyncComphad both an asyncsetupreturning a function AND arenderoption, which conflicts. Let me clean up the reproduction test (removing the redundantrenderon async components, matching the established test pattern).Assistant
The 4th test failure is a test-pollution artifact: each test appends a new
#targetdiv todocument.bodywithout cleanup, soquerySelector('#target')returns the oldest one. The actual crash scenarios (tests 1-3) all pass. Let me verify test 4 passes in isolation.Assistant
Test 4 passes in isolation, confirming the test-pollution artifact. The fix is correct. Now let me run the existing test suites to make sure nothing breaks.
Assistant
All existing tests pass. Let me also run the broader renderer test suite and the runtime-dom tests to be thorough.
Assistant
The runtime-dom tests are in a separate project (
unit-jsdom). Let me run the runtime-dom teleport/suspense tests separately. Let me find them.Assistant
Let me run the runtime-dom jsdom tests for useCssVars and customElement, and the e2e Transition tests which use teleport. Actually, the e2e tests require a browser build. Let me just run the runtime-dom jsdom project tests.
Let me run the
unit-jsdomproject for relevant files.Assistant
Let me run the full runtime-core test suite to be thorough.
Assistant
All tests pass except my temporary test 4 (the test-pollution artifact). Now, since I removed the
shouldRemove = falsereassignment,shouldRemoveis never reassigned, so it should beconstto avoid a lint warning. Let me fix that.Assistant
Now let me run lint/typecheck on the changed file to ensure no issues.
Assistant
Typecheck passes. Now let me clean up the temporary reproduction test file (per instructions, I should not add tests to the repo).
Assistant
The diff is clean. Let me re-run the key test suites once more after the
constchange to confirm everything still passes.Assistant
Let me also run the server-renderer tests involving teleport/hydration since the
removepath is used during hydration unmount too.Assistant
All tests pass. Let me verify there are no leftover temporary files.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.