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 and understanding the Teleport/Suspense unmount regression.
- Assistant
Let me examine the Teleport implementation and the related PRs mentioned in the issue.
- Assistant
Let me look at the Teleport.ts file, especially the remove function and pendingMounts related code.
- Assistant
Let me read more of the Teleport.ts file, particularly the remove function and pendingMount related code.
- Assistant
Let me look at the remove function more carefully.
- Assistant
Let me examine the unmount and unmountComponent functions to find where the null component crash occurs.
- Assistant
Let me look at the unmount and unmountComponent functions.
- Assistant
Let me inspect how deferred teleport mounting works and what state children are left in.
- Assistant
I should look at the mount deferred path in Teleport.ts.
- Assistant
Let me continue reading the mount path when pendingBranch is set.
- Assistant
Let me check recent tests and git history related to this bug.
- Assistant
Let me inspect the previous fixes and existing tests around this case.
- Assistant
Let me look specifically at the remove part of that PR, and also look at tests related to unmount.
- Assistant
Let me look at the related Suspense tests from that PR and also search for the crash reproduction.
- Assistant
I'll write a quick reproduction of the unmount crash, based on the description.
- Assistant
I'll confirm what happens in unmountComponent when the instance is null.
- Assistant
I'll implement the fix: when a pending mount exists, children were never mounted, so skip unmounting them entirely.
- Assistant
I need to navigate to the correct location first, then apply the edit.
- Assistant
Now I can apply the edit.
- Assistant
I'll create a temporary reproduction test to verify the crash was fixed, without modifying the repo tests.
- Assistant
I'll write a temporary reproduction test next.
- Assistant
Let me check how tests are run and execute the reproduction.
- Assistant
I need to put the test file somewhere vitest can pick it up, or run vitest with a path. Also the packages might need to be built since source changes may or may not be picked up via aliases.
- Assistant
I'll place a temporary test under the runtime-core tests, run it, then delete it.
- Assistant
Tests were hanging in watch mode — I'll rerun with
--run. - Assistant
Vitest may be stuck; I'll check the environment and try a more targeted run.
- Assistant
Corepack was prompting interactively — I'll enable it non-interactively and rerun.
- Assistant
Running the reproduction tests now.
- Assistant
Confirming the old code fails these cases by temporarily reverting the fix and re-running the repro:
- Assistant
Python wasn't available — I'll use Node to temporarily revert and confirm the crash.
- Assistant
Reproduction matches the issue. Next I'll run the existing Teleport and Suspense tests.
- Assistant
All existing tests passed. Cleaning up the temporary test file.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.