Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(reactivity): ensure watch cleanup on effect scope stop #12373

Merged
merged 7 commits into from
Nov 14, 2024

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Nov 13, 2024

close #12370

Copy link

github-actions bot commented Nov 13, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+72 B) 38 kB (+24 B) 34.2 kB (+25 B)
vue.global.prod.js 159 kB (+72 B) 57.9 kB (+25 B) 51.5 kB (-28 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47 kB (+72 B) 18.3 kB (+24 B) 16.8 kB (+65 B)
createApp 55.1 kB (+72 B) 21.3 kB (+23 B) 19.4 kB (+23 B)
createSSRApp 59.1 kB (+72 B) 23 kB (+25 B) 20.9 kB (+18 B)
defineCustomElement 59.8 kB (+72 B) 22.9 kB (+32 B) 20.8 kB (+22 B)
overall 68.8 kB (+72 B) 26.4 kB (+24 B) 24 kB (+25 B)

Copy link

pkg-pr-new bot commented Nov 13, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12373

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12373

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12373

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12373

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12373

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12373

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12373

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12373

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12373

vue

pnpm add https://pkg.pr.new/vue@12373

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12373

commit: 0073a01

@huodoushigemi
Copy link

👍

@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: reactivity ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Nov 13, 2024
@edison1105 edison1105 changed the title fix(reactivity): ensure watch cleanup on effect stop fix(reactivity): ensure watch cleanup on effect scope stop Nov 13, 2024
Copy link
Contributor

@skirtles-code skirtles-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've posted a comment at #12370 (comment). I don't think it actually is a memory leak.

I'm not sure whether the use case presented on that issue is valid, but if I'm understanding correctly, the objective here is just to improve the teardown handling within EffectScope, so that the effects aren't retained after the scope is stopped.

packages/reactivity/src/watch.ts Outdated Show resolved Hide resolved
@edison1105
Copy link
Member Author

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Nov 14, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue failure success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@vue-bot
Copy link
Contributor

vue-bot commented Nov 14, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success success
nuxt success success
pinia success success
primevue success success
quasar success success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@yyx990803
Copy link
Member

I separated the fix for #5783 in 2193284

@yyx990803 yyx990803 merged commit bee2f5e into main Nov 14, 2024
15 checks passed
@yyx990803 yyx990803 deleted the edison/fix/cleanup_watch branch November 14, 2024 06:24
@@ -119,17 +119,24 @@ export class EffectScope {
if (this._active) {
this._active = false
let i, l
for (i = 0, l = this.effects.length; i < l; i++) {
this.effects[i].stop()
const effects = this.effects.slice()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for what reason do you need to make this slice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change was for #5783. it's not necessary since #5783 fixed via 2193284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. ready to merge The PR is ready to be merged. scope: reactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Memory leak
7 participants