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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
This is the Vue.js core repository. Let me explore the packages directory.
Assistant
Let me look at the full file to understand the
removemethod:Assistant
Now let me look at the unmount function in the renderer:
Assistant
I understand the issue. Let me look at the existing tests for teleport to understand the testing setup:
Assistant
let me first reproduce the issue. Let me create a test script:
Assistant
The test file is in
packages/runtime-core/__tests__/, which is for the unit tests. Let me move the test file to runtime-dom or use the proper approach to test it. Let me look at how other Teleport tests are organizedAssistant
The test passed but doesn't actually trigger the issue. Let me create a more accurate reproduction:
Assistant
I've reproduced the exact error from the issue. Let me look at the relevant code in detail:
Assistant
I understand the issue. When
pendingMountexists, the children were never mounted, so they havevnode.component === null. The fix should skip the children unmount loop entirely inTeleportImpl.removewhen there's a pendingMount.Let me now look at the entire
removemethod to understand exactly where to apply the fix:Assistant
Now I'll apply the fix. The pendingMount means the teleport's children were never mounted, so we should skip the entire children unmount loop:
Assistant
Now let me run the reproduction test to see if it works:
Assistant
The test passes. Let me test more edge cases:
Assistant
I need to fix the test to wait for the right mount order. Let me use a different approach:
Assistant
All 4 tests pass. Now let me run the existing Teleport tests to make sure my fix doesn't break anything:
Assistant
All existing tests pass. Now let me also run the broader tests to make sure I haven't broken anything else:
Assistant
All 3165 unit tests pass. Let me also run the unit-jsdom tests:
Assistant
All tests pass. Now let me clean up my reproduction file before submitting:
Assistant
Let me also verify the fix once more by looking at the diff:
Assistant
Let me also check the fix once more by running the existing tests:
Assistant
Let me also create a temporary test specifically modeled on the issue to verify:
Assistant
Let me also verify that the test fails without the fix to confirm that we have a correct reproduction:
Assistant
The reproduction test fails without the fix and passes with the fix. Let me confirm the fix is back in place:
Assistant
Let me also run all the tests once more to make sure everything is good:
Assistant
All 3165 tests pass. Let me also run the unit-jsdom tests:
Assistant
All tests pass. Let me look at the final state of the fix:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.