Skip to content

fix(reactivity): release computeds read outside of their scope on stop - #16429

Open
ValentinYoushkevich wants to merge 1 commit into
vuejs:minorfrom
ValentinYoushkevich:fix/reactivity-release-scoped-computed
Open

ValentinYoushkevich wants to merge 1 commit into
vuejs:minorfrom
ValentinYoushkevich:fix/reactivity-release-scoped-computed

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

close #16390

A computed created in setup() and read only outside of effects, e.g. in an event handler, stays subscribed to what it reads, so a long-lived store keeps it, and through its getter the unmounted component, alive.

Nothing owned such a read. I made a computed remember the scope it was created in: a read outside of any scope counts as a read there unless something already keeps the computed, so unmount releases it. This replaces the SSR-only link from #16013. A stopped scope now drops its cleanups, so the computed's reference to it stays cheap.

Once that scope has stopped, every read without a subscriber recomputes, as reads in a stopped scope do since #16114. The extra field costs a few ns per computed() and 16 B gzip.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ce2302b4-2c9d-4e86-a600-e3af92bbd5fb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pkg-pr-new

pkg-pr-new Bot commented Nov 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@16429
npm i https://pkg.pr.new/@vue/compiler-core@16429
yarn add https://pkg.pr.new/@vue/compiler-core@16429.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@16429
npm i https://pkg.pr.new/@vue/compiler-dom@16429
yarn add https://pkg.pr.new/@vue/compiler-dom@16429.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@16429
npm i https://pkg.pr.new/@vue/compiler-sfc@16429
yarn add https://pkg.pr.new/@vue/compiler-sfc@16429.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@16429
npm i https://pkg.pr.new/@vue/compiler-ssr@16429
yarn add https://pkg.pr.new/@vue/compiler-ssr@16429.tgz

@vue/compiler-vapor

pnpm add https://pkg.pr.new/@vue/compiler-vapor@16429
npm i https://pkg.pr.new/@vue/compiler-vapor@16429
yarn add https://pkg.pr.new/@vue/compiler-vapor@16429.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@16429
npm i https://pkg.pr.new/@vue/reactivity@16429
yarn add https://pkg.pr.new/@vue/reactivity@16429.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@16429
npm i https://pkg.pr.new/@vue/runtime-core@16429
yarn add https://pkg.pr.new/@vue/runtime-core@16429.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@16429
npm i https://pkg.pr.new/@vue/runtime-dom@16429
yarn add https://pkg.pr.new/@vue/runtime-dom@16429.tgz

@vue/runtime-vapor

pnpm add https://pkg.pr.new/@vue/runtime-vapor@16429
npm i https://pkg.pr.new/@vue/runtime-vapor@16429
yarn add https://pkg.pr.new/@vue/runtime-vapor@16429.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@16429
npm i https://pkg.pr.new/@vue/server-renderer@16429
yarn add https://pkg.pr.new/@vue/server-renderer@16429.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@16429
npm i https://pkg.pr.new/@vue/shared@16429
yarn add https://pkg.pr.new/@vue/shared@16429.tgz

vue

pnpm add https://pkg.pr.new/vue@16429
npm i https://pkg.pr.new/vue@16429
yarn add https://pkg.pr.new/vue@16429.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@16429
npm i https://pkg.pr.new/@vue/compat@16429
yarn add https://pkg.pr.new/@vue/compat@16429.tgz

commit: f20429d

@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 87.5 kB 30.7 kB 26.9 kB
runtime-dom.global.prod.js 126 kB (+64 B) 47 kB (+21 B) 42.1 kB (+14 B)
vue.global.prod.js 186 kB (+64 B) 67.3 kB (+21 B) 59.8 kB (-44 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 55.8 kB (+21 B) 21.7 kB (+2 B) 19.8 kB (+29 B)
createApp 65.1 kB (+64 B) 25.1 kB (+14 B) 22.8 kB (+10 B)
createApp + vaporInteropPlugin 126 kB (+64 B) 46.1 kB (+14 B) 41.4 kB (+40 B)
createVaporApp 36.2 kB (+21 B) 13.9 kB (+1 B) 12.7 kB (+6 B)
createSSRApp 70 kB (+64 B) 27.1 kB (+14 B) 24.6 kB (+9 B)
createVaporSSRApp 44.4 kB (+21 B) 16.9 kB (+2 B) 15.6 kB (+8 B)
defineCustomElement 71.6 kB (+64 B) 27.1 kB (+14 B) 24.6 kB (+20 B)
defineVaporCustomElement 51.2 kB (+21 B) 18.7 kB (+3 B) 17.2 kB (+34 B)
overall 82.3 kB (+64 B) 31.1 kB (+15 B) 28.1 kB (+15 B)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant