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
Reproduced exactly. Now let's fix the
unmountfunction orunmountComponentto guard against null component, or better, fixTeleportImpl.removeto skip unmounting children entirely (not just DOM removal) when pending mount hasn't run.Assistant
No crash, just history expansion issue in bash. That's expected/fine since it's just my temp test's assertion. Let's remove temp test file and run the real test suites.
Assistant
All existing tests pass. Now let's also test the scenario from the reproduction repo more precisely - element children instead of component children, disabled teleport, moveTeleport edge cases, and also test unmounting the whole app (not just Suspense) directly containing pending teleport.
Assistant
This is a much better pattern (async component vs
defineAsyncComponentfrom vue itself). Let me rewrite my test with this pattern.Assistant
All edge cases pass. Now let's clean up temp test files and run the full runtime-core test suite plus runtime-dom to be safe.
Assistant
All 1244 tests pass (1 skipped, unrelated). Let's view the final diff.
Assistant
This looks clean. Let's double check for any leftover repro test files and run lint/type-check.
Assistant
Type-checking passes with no errors. Let's also run the eslint check on this file specifically.
Assistant
Lint is clean too. Let's do a final full test run to be thorough, then submit.
Assistant
These failures are unrelated e2e Puppeteer/browser sandbox issues in this environment, not related to my fix. All non-e2e tests (1391 passed) succeeded.
Assistant
Now let's go through the checklist explicitly:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.