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 inspect the repository and the Teleport/Suspense unmount implementation, trace the regression around pending mounts, then make the smallest runtime fix. I’ll run the relevant existing tests (and, if needed, a temporary reproduction) before reviewing the diff and submitting.
- Assistant
The failure is confirmed by the current control flow:
TeleportImpl.removedetects and disposes a pending mount, but still iterates its unmounted children. Component children havecomponent === null, sounmount()callsunmountComponent(null, ...). Since a pending teleport has not mounted any content, the correct behavior is to dispose the job, remove only the teleport’s main-view anchor when requested, and return without unmounting children. I’ll inspect nearby tests/history for conventions and then patch this path. - Assistant
The historical commits show the existing guard was introduced in the exact regression chain but only changes
shouldRemove; it does not prevent child traversal. I’ll preserve normal behavior for already-mounted teleports and add an early return only when the pending job is found, while retaining the existingdoRemovehandling for the main anchor. - Assistant
The source edit completed, but the test command was blocked because Corepack attempted to download the repository-pinned pnpm version and asked for confirmation. I’ll verify the edit, use the locally available package tooling if possible, and run the focused test without modifying repository tests.
- Assistant
The focused Teleport suite now passes all 51 tests, and ESLint passes for the changed file. The fix is narrowly scoped: pending teleports return before any child unmount, while ordinary teleports retain the prior removal logic. I’ll run the TypeScript check (or the relevant build validation), inspect the final diff, and then submit.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.