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 look at the Teleport implementation and the recent PRs mentioned in the issue.
- Assistant
Let me look at the Teleport.ts file, particularly the remove function.
- Assistant
Let me read more of the Teleport.ts file, especially the remove function and pendingMounts related code.
- Assistant
Let me look at the remove function more carefully.
- Assistant
Let me look at the unmount and unmountComponent functions in the renderer.
- Assistant
Let me read the unmount function around line 2173.
- Assistant
Looking at the remove path more carefully and related tests — the pending-mount path still unmounts component children even when they never mounted.
- Assistant
Let me search the tests and git history for related fixes.
- Assistant
There's a test for #14701. Let me look at that and also the related PRs that fixed similar issues.
- Assistant
Let me look for other related tests around the 14640 fix and the reproduction scenario.
- Assistant
Let me look at the tests around line 2484 and 2525 which deal with unmounting teleports inside suspense.
- Assistant
Let me re-read the full
removefunction and the deferred mount path, then reproduce with a test case. - Assistant
Let me check how Teleport is unmounted in the renderer.
- Assistant
Let me look at the unmount TELEPORT path.
- Assistant
Let me look at unmountComponent to confirm the crash.
- Assistant
Let me look at unmountComponent.
- Assistant
I understand the bug. I'll write a small reproduction test next, then fix
TeleportImpl.removeto skip unmounting never-mounted children. - Assistant
Let me check how tests are run and create a quick reproduction.
- Assistant
I'll write a temporary reproduction test based on the issue.
- Assistant
Let me verify the test file was written correctly.
- Assistant
The create command didn't write the contents properly. Let me try another approach.
- Assistant
Now I'll run the reproduction tests to confirm the crash.
- Assistant
The test timed out. Let me check how to run tests properly.
- Assistant
Let me try running vitest with run mode so it doesn't watch.
- Assistant
Hmm, vitest is timing out. Let me try without filtering project, or check if there's an environment issue.
- Assistant
Corepack is prompting interactively. I'll enable pnpm non-interactively and retry.
- Assistant
Good, now let's try running the test again.
- Assistant
I've reproduced the crash. Let me check the related PR diffs for the intended fix approach.
- Assistant
Let me look at PR #14642 more carefully.
- Assistant
Let me see the remove function change in that PR.
- Assistant
Let me get the remove function part of the diff specifically.
- Assistant
I'll update
TeleportImpl.removeso it skips unmounting children when a pending mount was never completed. - Assistant
I'll fix the remove function to skip children unmount when pending.
- Assistant
Now let me re-run the reproduction tests to verify the fix.
- Assistant
Reproduction tests pass. Running existing Suspense and Teleport tests next.
- Assistant
Let me extend the reproduction with more edge cases to ensure the fix is solid.
- Assistant
Edge cases are covered (the multi-child assertion was just about null rendering). Cleaning up the temporary test and verifying related suites once more.
- Assistant
Let me verify the final diff.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.