Skip to content

Top-level await in <script setup> leaks reactive effects when the component is abandoned before the await resolves #14777

@Mini-ghost

Description

@Mini-ghost

Vue version

3.5.33

Link to minimal reproduction

https://play.vuejs.org/#eNqtVN9v00AM/lesvCTVQlpUxsNoCwPtAR5g2gYvBKE0cbvbLndR7i4dqvq/Y19+tLAxpGlvsf3Z/vydnW1wWlVJ4zA4CWYmr0VlwaB11SJVoqx0bWELuS4rZ7GIoap1IwqMwVxnUurNBa5gB6talxBSkTBVQ9rpUjvbhZKxt7hP+GZAfDVYDwA2+niqcq2MhSy3okGYH3SLwowrhaM96gOxI0xPMopGMF90uUmTSUcV5nPoEuFtx+zE9z+oo1y5JEJ/dJtQvJs5CltAGHdICs3GrWQkFhkWy0pmFskCmC2dtVrBu1yK/HaeBi2tNvXoKA0WRy9n4xa0gO22b7/b+WyZLVH6QmQIRZNB86LUBUoq1c6WBmB/VUh2nRVCk6mykk1Wgiw/OqN5XLLHXTk/vm8y3nd5zoaOdD3oxzLfa3fpTIXKtFqRzSW0QkXvIgzV4EcdaszGB/DZ+EDnIA6soedbiXVyY7SiLd5yRstJSKy/VFbQ86bBCfgIx/zzfvI+WzuMe39+jfntA/4bc8e+NDivkYZhJYaYzeo1krwcPrv8jHf0PQRJPycJ/UjwAo2Wjjm2sPdOFUT7AOfZfvQnI9T6ypzdWZKiH4qJMnLn8WlAJ8Ta/Wv0Pd1p8srnpWpHKg73+dh/QKgbzG0Mm8zm1/fu3nujFjMcyyiGyO+F335Pg69NS0ykXkfh96Hxj/4CXFXQ4xZ0Z20iEfzPqRWiub/brfPvbel/M08fc+UUXQNdtpGIFUSloV/GdDIZtdPVVK1WoHAD55QnDEa0NFryf6wTALjllSiRuPbBGEpDU9J78LzcJ9tkgshxk+h4QvWfrnE/9LNIvD/nhxX+2WDN20kKT5PjZDplnzXfBu/rZJJMg91v4JQtHg==

Steps to reproduce

  1. Open the minimal reproduction and open the Console panel in the browser developer tools.
  2. Click the user radio input.
  3. Within 5 seconds, switch back to the about radio input.
  4. Wait for 5 seconds.
  5. Click the +1 button.
  6. At this point, the Console will show:
[About.vue] number updated 1
[User.vue] number updated 1

What is expected?

Only the watcher callback in About.vue should run after clicking the +1 button. User.vue should not log any update because the view has already been switched back to about.

What is actually happening?

[About.vue] number updated 1
[User.vue] number updated 1

System Info

  System:
    OS: macOS 15.6.1
    CPU: (8) arm64 Apple M1
    Memory: 130.75 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.18.0 - /Users/alexliu/.nvm/versions/node/v22.18.0/bin/node
    npm: 10.9.3 - /Users/alexliu/.nvm/versions/node/v22.18.0/bin/npm
    pnpm: 10.33.0 - /Users/alexliu/Library/pnpm/pnpm
  Browsers:
    Chrome: 147.0.7727.138
    Edge: 147.0.3912.98
    Safari: 18.6
    Safari Technology Preview: 26.0

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions