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
Duplicate
},at line 365. Let me fix.Assistant
Now let's check the whole remove function again for correctness and check TypeScript build.
Assistant
Let's find existing tests for teleport unmount and run test suite instead, which will use vite/vitest with esbuild (not strict tsc check needed, but good to verify types separately with a quick check).
Assistant
Let's create a reproduce script using vitest directly.
Assistant
Let's put the test in packages/vue/tests instead, matching include patterns.
Assistant
Now let's verify this test fails without the fix (checkout original code temporarily) to confirm it truly reproduces the issue.
Assistant
Also add debug in remove() to see if pendingMount found there.
Assistant
Good, file restored to original (unfixed) without debug now. Let's re-add debug logs carefully using python-free approach with
perlor manual edit tool.Assistant
Now update the test file to add markers before/after second render call, without using
!!in sed.Assistant
Reproduced the exact error from the issue. Now let's clean up debug logs and apply the fix, then verify.
Assistant
Good, that's the intended fix. Let's pop it back.
Assistant
Now let's run the reproduction test with the fix applied.
Assistant
The fix resolves the crash. Now let's also verify with element children (not just component children) still works correctly, and run the full existing test suites for Teleport and Suspense.
Assistant
All existing tests pass. Let's also test with element (non-component) children in a similar pending scenario, and run the full runtime-core test suite for broader confidence.
Assistant
Both element and component children scenarios pass. Now let's run the broader runtime-core test suite to make sure nothing else broke.
Assistant
All 1014 tests pass. Let's also run runtime-dom tests since Teleport interacts with DOM specifics.
Assistant
Failures are unrelated puppeteer/e2e sandbox issues (environment limitation, not related to our fix). Non-e2e tests all pass (379 passed).
Assistant
All non-e2e tests pass, including our reproduction tests. Now let's clean up temporary test files before submitting (should not add new tests to the repo per instructions).
Assistant
Let's do a final review of the diff.
Assistant
Now let's run lint/typecheck to confirm no issues, and rerun the test suites once more.
Assistant
Lint passes cleanly. Let's do a final check of the full diff and git status before submission.
Assistant
The fix is minimal, focused, and correctly resolves the issue. Let me review the checklist one more time before submitting.
Assistant
No type errors related to Teleport.ts. Let's run the full tsc to be safe (could take a while, but let's check overall exit status).
Assistant
TypeScript compiles cleanly with no errors. Now let's do one final full test run to confirm everything is good, and check git status is clean of stray files.
Assistant
Everything passes cleanly, working tree is clean of temp files. Now let's go through the checklist.
Checklist review:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.