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's use the editor tool instead.
Assistant
Now let's write a reproduction test to confirm the fix.
Assistant
Let's look at these existing test patterns to build an accurate repro of the exact crash scenario (Suspense unmounted while Teleport is pending, with a component child inside Teleport).
Assistant
Good, but let's check whether this test actually fails without the fix.
Assistant
Let's fix this line with the editor.
Assistant
Now let's add a log at remove() to see ordering, and also add a marker before/after both render calls in the test.
Assistant
Reproduced exactly the reported error. Now let's re-apply the fix and confirm it resolves this.
Assistant
The fix resolves the confirmed reproduction. Now let's check other related scenarios: disabled teleport, array children with mixed elements, and DISPOSED job re-triggering (patch after unmount edge case). Let's also run the whole Teleport and Suspense test suites.
Assistant
All existing tests pass. Now let's run the broader runtime-core test suite to be safe, plus runtime-dom.
Assistant
All tests pass. Now let's think about edge cases more carefully:
- Disabled teleport with pending mount, unmounted before resolve.
- Non-array children (shouldn't happen but check ShapeFlags).
- The
n1 == nullbranch'squeuePendingMountreused when patching (n1 present, pendingMount replaced) - unaffected by our remove() change but let's verify moveTeleport still works given remove() changes.
Assistant
All edge cases pass including confirming normal functionality (mount to target after resolve, unmount after normal use) still works correctly. Now clean up temp test file and do a final full test run.
Assistant
Now let's run full test suite for runtime-core and runtime-dom once more, plus type check to be safe.
Assistant
All pass. Let's also run a TypeScript check on the changed file to make sure no type errors introduced.
Assistant
No type errors related to our change. Let's view the final diff once more for clarity.
Assistant
This is a minimal, targeted fix. Let me go through the checklist now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.