Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION Teleport + Suspense: unmount crashes on pending teleport with…

  1. 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
    
    1. Open the browser DevTools console.
    2. Click "Unmount Suspense".
    3. Observe TypeError: Cannot read properties of null (reading 'type') in the console

    Option 2 — Tests (additional)

    pnpm test
    

    The repo also contains three Vitest tests in tests/teleport-unmount.test.js

    What 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.34
    

    Any additional comments?

    This is a continuation of the regression chain that started in 3.5.31:

    • PR #8619 (3.5.31) introduced pendingMounts so teleports defer their mount when parentSuspense.pendingBranch is set. This is what created the situation where a teleport's children can have vnode.component === null.
    • Issue #14640 + PR #14642 (3.5.32) added the pendingMount check shown above. That gates DOM removal of element children, not the unmountComponent(null, …) call on component children.
    • Issue #14699 (3.5.32) reported the same crash with the same stack as this issue. Closed by the author with a note about re-filing with a more accurate reproduction.
    • Issue #14701 + PR #14702 (3.5.33) added pendingMounts.has(vnode) guard, but only in moveTeleport. The TeleportImpl.remove path was not touched, so 3.5.33 and 3.5.34 still crash.

    Interface

    No new interfaces are introduced.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /core, current file: none) bash-$

  2. Assistant

    I'll start by exploring the repository to understand its structure and locate the relevant files. Let's first check what's in the root directory.

  3. Assistant

    This is the Vue.js core repository. Let me explore the packages directory to find the runtime-core package where the Teleport implementation likely is.

  4. Assistant

    Let me look at the Teleport implementation and find the remove method that's mentioned in the error stack trace.

  5. Assistant

    Let me look at the remove method of TeleportImpl to understand the issue.

  6. Assistant

    Let me open the file around line 317 to see the remove method.

  7. Assistant

    Now let me look at the renderer to understand the unmount function and how it handles component vnodes.

  8. Assistant

    Let me search for the unmount function in the renderer.

  9. Assistant

    Let me look at the unmount function and the unmountComponent function in the renderer.

  10. Assistant

    Now let me look at the unmountComponent function to understand how it handles null components.

  11. Assistant

    Now I understand the issue! Let me look at the error reproduction to confirm. The error occurs in the remove method of TeleportImpl when it tries to unmount children of a teleport that was never mounted. When a teleport is inside a pending suspense, its children may have vnode.component === null because they were never instantiated. The current code checks for pendingMounts and sets shouldRemove = false, but it still tries to unmount the children, which calls unmountComponent(vnode.component!, ...) where vnode.component is null.

    Let me first reproduce the error by creating a simple test script:

  12. Assistant

    Let me look at the existing Teleport tests to understand the patterns used, and also check the git log for recent changes.

  13. Assistant

    Now let me look at the exact remove method again more carefully to understand the flow:

  14. Assistant

    Let me look at the full remove method.

  15. Assistant

    Now I understand the issue clearly. Let me also look at how the moveTeleport handles the pendingMounts check:

  16. Assistant

    Now I understand the issue completely. Let me trace through the logic:

    1. The TeleportImpl.remove() method correctly detects pendingMount and sets shouldRemove = false
    2. But it still iterates over children and calls unmount() on each child
    3. For component children that were never mounted (because the teleport was pending/deferred), vnode.component is null
    4. In the unmount function (renderer.ts line 2172-2173), it accesses vnode.component! which is null, causing the crash

    The fix is straightforward: when pendingMount is set (meaning the teleport was never mounted), we should skip unmounting the children since they were never mounted. This is analogous to the fix in moveTeleport (line 397) which skips moving children when there's a pending mount.

    Let me check existing tests first:

  17. Assistant

    Let me look at the process method to understand when target markers are created:

  18. Assistant

    Now I understand the issue clearly. Let me trace through the code:

    1. In TeleportImpl.remove(), when there's a pendingMount (teleport was never mounted because it's inside a pending suspense), the code correctly:

      • Disposes the pending mount job
      • Deletes from pendingMounts map
      • Sets shouldRemove = false
    2. However, it still proceeds to iterate through children and calls unmount() on each child. For component children that were never mounted, vnode.component is null, and the unmountComponent function at line 2173 accesses vnode.component! which is null, causing the crash.

    The fix is simple: when there's a pendingMount, we should skip unmounting the children entirely, since they were never mounted. This is analogous to what was done in moveTeleport at line 397 where children are skipped if they're in a pending mount.

    Let me also check the unmount function to understand the full picture:

  19. Assistant

    Now I understand the issue completely. In TeleportImpl.remove():

    1. When pendingMount exists, shouldRemove is set to false and the pending mount is cleaned up
    2. BUT the code still proceeds to iterate through children and calls unmount() on each child
    3. For component children, unmount() at line 2173 calls unmountComponent(vnode.component!, ...) but vnode.component is null because the component was never mounted

    The fix is to skip unmounting children when there's a pending mount, similar to how moveTeleport skips moving children when there's a pending mount (line 397).

    Let me apply the fix:

  20. Assistant

    Now I need to understand the mount flow better. Let me look at the full mount logic in the process method:

  21. Assistant

    Now I fully understand the issue. When a teleport is deferred or inside a pending suspense, queuePendingMount(n2) is called and the method returns early without calling mountToTarget(). This means:

    1. targetStart and targetAnchor are never set
    2. Children are never mounted, so their component is null

    When remove() is called:

    1. It correctly detects pendingMount and sets shouldRemove = false
    2. But it still tries to hostRemove(targetStart!) and hostRemove(targetAnchor!) (which may be undefined)
    3. It still iterates children and calls unmount(), which calls unmountComponent(vnode.component!, ...) with null component

    The fix: when pendingMount is found, skip ALL removal logic (target markers and children), since nothing was ever mounted. We've already disposed the queued mount job.

    Let me apply the fix:

  22. Assistant

    The fix looks correct. Now let me verify it works by running the existing tests:

  23. Assistant

    I see - the tests are failing because when a teleport is removed with a pending mount, the anchor comment node is not being cleaned up. The el and anchor are always created during the initial process call, even when the mount is deferred. So we need to still clean those up.

    Let me look at what gets created during mount:

  24. Assistant

    I see - the issue is more nuanced. When a teleport is deferred, its el and anchor (main view anchors) are always created during process, but targetStart and targetAnchor are only created when mountToTarget() runs (which hasn't happened yet for pending mounts). So we need to still remove the main anchor but skip the target markers and children.

    Let me update the fix:

  25. Assistant

    Now let me run the tests again:

  26. Assistant

    All Teleport tests pass. Now let me run the Suspense tests too:

  27. Assistant

    Now let me create a reproduction script to verify the fix addresses the exact issue described:

  28. Assistant

    Let me check how to build the project.

  29. Assistant

    Let me check if there's already a built version:

  30. Assistant

    Let me build the project:

  31. Assistant

    The build requires rollup which isn't available. Let me write a proper test using vitest instead. Let me first look at the existing test patterns:

  32. Assistant

    Let me look at the existing discard tests more closely:

  33. Assistant

    Now let me write a test that specifically reproduces the bug described in the issue - Teleport + Suspense with component child:

  34. Assistant

    Let me write a quick test directly in a temp file that will be picked up by vitest:

  35. Assistant

    All 51 Teleport tests pass. Now let me write a direct reproduction test to confirm the fix works for the exact issue scenario (teleport with component child inside suspense that gets unmounted before mount):

  36. Assistant

    All Suspense tests pass too. Now let me create a specific test for the exact bug scenario described in the issue:

  37. Assistant

    Let me create the test file in the right location within the project so it can be picked up by vitest.

  38. Assistant

    The unit test project doesn't have a DOM environment. Let me check how the existing Teleport tests handle this:

  39. Assistant

    I see, I need to add @vitest-environment jsdom annotation. Let me fix my test file:

  40. Assistant

    Both reproduction tests pass. Now let me clean up the temp test file and run the full test suite:

  41. Assistant

    Now let me run the full runtime-core test suite:

  42. Assistant

    All 1014 tests pass. Let me verify the final state of the change:

  43. Assistant

    The change is minimal and clean. Let me verify the final state of the fix:

  44. Assistant

    Let me also run a broader set of tests to make sure nothing else is broken:

  45. Assistant

    The only failure is an unrelated performance test (should not lead to exponential perf cost with deeply chained computed) which is a flaky timing test. All 3164 other tests pass, including all 51 Teleport tests and 57 Suspense tests.

    Let me verify my change is complete and correct one more time:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.