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)
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
Let me start by understanding the repository structure and the issue. The issue is about a Teleport + Suspense bug where unmounting crashes on a pending teleport with a component child. The error is
TypeError: Cannot read properties of null (reading 'type')inunmountComponent.Let me first explore the repository structure to understand the codebase.
Assistant
Let me look at the packages directory to understand the structure better.
Assistant
Let me look at the Teleport-related code in runtime-core and understand the issue.
Assistant
Let me look at the Teleport.ts file first.
Assistant
Let me try the correct format for the open command.
Assistant
Let me scroll down to see the relevant parts.
Assistant
Let me see more of the file, especially the
removefunction.Assistant
Let me continue to find the
removefunction.Assistant
Now I can see the issue. Let me look at
unmountComponentin the renderer to understandAssistant
Let me look at the
unmountComponentfunction and theunmountfunction around itAssistant
Let me look at the
unmountfunction to see how it dispatches to `unmountComponentAssistant
Let me look at the
unmountfunction starting at line 2120.Assistant
Now I can see the problem clearly. Let me also look at the
moveTeleportfunction for completeness:Assistant
Now I understand the issue clearly. Let me look at the existing test file for Teleport to understand the test patterns:
Assistant
Let me also search for Suspense-related tests in Teleport:
Assistant
Let me create a reproduction script to confirm the bug. First, let me understand the test infrastructure:
Assistant
Let me create a temporary reproduction script to confirm the bug:
Assistant
Let me run the existing Teleport tests to see if there's already a failing test:
Assistant
Now I have a clear understanding of the bug. Let me create a small reproduction test and then fix it.
The issue is in
TeleportImpl.removeat lines 338-343: when there's a pending mount,shouldRemoveis set tofalsebut children are still unmounted. For component children that were never mounted,vnode.componentisnull, causing the crash inunmountComponent.Let me first write a quick inline test to reproduce
Assistant
Let me check the vitest config to see how to run a quick test:
Assistant
I have a clear understanding of the bug. Let me apply the fix now. The issue is that
TeleportImpl.removedisposes the pending mount but still tries to unmount children that were never mounted.Assistant
Now I'll apply the fix. The children loop in
removeshould be guarded like it is inmoveTeleport(line 397). When there's a pending mount, we should skip unmounting children entirely:Assistant
The
!is being interpreted by bash. Let me use the proper quoting:Assistant
The fix is applied. Now let me run the existing Teleport tests to make sure nothing is broken
Assistant
All Teleport tests pass. Let me also run suspense tests and the full unit test suite
Assistant
Good. Let me also run the full unit test suite for runtime-core to make sure nothing is
Assistant
All 3165 tests pass. Let me verify the diff
Assistant
The fix is clean and minimal. Let me clean up the temporary file I created:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.