Teleport + Suspense: unmount crashes on pending teleport with component child…
- User
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)
bashpnpm 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)
bashpnpm 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:
codeTypeError: 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
shellSystem: 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.34 - Assistant
Now let me check how the renderer's
unmount/removeinteracts with Teleport: - Assistant
Now let me check the Suspense
resolve/unmountpaths since the crash stack goes throughSuspense.resolve: - Assistant
Let me see Suspense's
unmountmethod: - Assistant
Now I'll add regression tests after the #14701 test:
- Assistant
Now run the tests:
- Assistant
The crash is fixed — the
<!---->is just the comment placeholder from renderingnull. Let me fix the assertions: - Assistant
The second test now avoids the Teleport crash but exposes different behavior. Let me check
unmountComponent's suspense deps handling: - Assistant
All 59 pass. Now verify the new tests actually fail without the fix:
- Assistant
All checks pass. Summary of the fix:
Root cause
Since PR #8619 (3.5.31), a Teleport inside a Suspense with a pending branch defers its mount via
queuePendingMount. If the teleport is unmounted before that job runs, its children vnodes were never mounted — component children havevnode.component === null.The #14640 guard in
TeleportImpl.removeonly setshouldRemove = false, which prevents DOM removal for children — but it still passed every child through . For children that hits in renderer.ts:2173 with → . (PR #14702 fixed the same gap only in , not .)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.