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 the
Assistant
This is the Vue.js core repository. Let me explore the structure further
Assistant
Let me look at the file with the remove method in more detail
Assistant
Now let me look at the
unmountfunction in the renderer to understand what happens when the component isnull:Assistant
Assistant
Let me look at existing teleport tests:
Assistant
Now let me create a reproduction script to confirm the issue:
Assistant
me look at the Suspense.ts file to understand how unmount happens:
Assistant
Let me reproduce the issue using a test script.
Assistant
Let me look at how teleport suspense tests are done elsewhere:
Assistant
Let me check how the
Teleportis integrated with suspense in existing tests:Assistant
Let me check how to properly write a test with Teleport and Suspense together:
Assistant
let me write a proper reproduction test:
Assistant
Now I can reproduce the issue. Let me look at the unmount function to understand all the paths:
Assistant
Now I understand the issue. Let me apply the fix to
TeleportImpl.remove. The simplest and most consistent approach is to skip unmounting children when there's a pending mount, similar tomoveTeleport:Assistant
Now let me apply the fix. I'll modify the
TeleportImpl.removeto skip unmounting children when there's a pending mount:Assistant
Let me write the script to a file and run it:
Assistant
Now let me run the reproduction test:
Assistant
The TypeError is gone now. The remaining assertion failure is unrelated to our fix - my test assertion is wrong. Let me look at how Suspense unmount works:
Assistant
Let me look at the original test setup more carefully to understand what's happening:
Assistant
test passes with the fix. Let me revert temporarily to confirm the test catches the issue:
Assistant
Confirmed the reproduction. Now let me restore the fix:
Assistant
let me run the existing teleport and suspense tests to make sure I haven't broken anything:
Assistant
tests pass. Let me also run the broader runtime-core tests:
Assistant
Let me check what other edge cases need to be considered. Let me also look at what happens if the teleport has been disabled:
Assistant
me also write a test for the
deferprop case (not just suspense pending branch):Assistant
The second test isn't set up right. Let me look at how existing tests use
defer:Assistant
Let me check the test renderer to understand the deferred mount timing:
Assistant
Now let me also add a test case for the issue to the actual existing tests. But first, let me also check the existing test that was supposed to cover the case but didn't:Now let me look at the existing related tests to understand if a test should be added in the official test file:
Assistant
Let me look at the tests in the original repro to understand the test environment:
Assistant
Let me look at the existing test for moving teleport with component children:
Assistant
I need to remove my test file since I shouldn't add new tests. Let me clean up:
Assistant
Good. Now let me think about edge cases more thoroughly.
Let me re-read the diff to make sure my fix is right:Let me look at my fix once more and think about edge cases:
Assistant
Let me look at how patches and unmounts work in the patch flow:
Assistant
Let me also look at how the patch handles different n1/n2 combinations:
Assistant
Let me run all the related tests one more time to confirm:
Assistant
All tests pass. Let me also run the runtime-dom and vue tests:
Assistant
The vue package failures are puppeteer/sandbox issues, unrelated to my fix. Let me confirm by running just the non-puppeteer tests:
Assistant
All the e2e tests use puppeteer. Let me skip those and just run the non-e2e tests:
Assistant
Let me also create a more comprehensive test in a temp file to verify all edge cases:
Assistant
Let me update test 3:
Assistant
All 3 edge cases pass. Let me also test a more complex case where the teleport's children include nested components:
Assistant
All edge cases pass. Let me clean up the test files:
Assistant
Let me also verify the fix is correct:
Assistant
The fix is minimal. Let me run all the relevant tests one more time:
Assistant
All 1014 tests pass. Let me look at the final diff:
Assistant
Let me do a final check of the entire Teleport.ts to make sure my change is clean:
Assistant
Let me also make a quick check that the test file I created is no longer there:
Assistant
Let me also create one more test scenario to ensure the unmount works correctly when the teleport has been successfully mounted:
Assistant
All tests pass. Now let me clean up:
Assistant
Let me run the all the related tests one final time to confirm:
Assistant
All 1535 tests pass. Let me also check the final diff one more time:
Assistant
Let me also write a brief summary and verify the fix is correct by checking the final state of the file:
Assistant
The fix is clean. Let me also do a final summary of the reasoning and verify the checklist:
Assistant
Let me also do a final check by running all the affected test suites:
Assistant
All 1535 tests pass. Let me also run a final check to make sure I don't have any leftover files:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.