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(watch): watchEffect clean-up with SSR #12097

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

skirtles-code
Copy link
Contributor

@skirtles-code skirtles-code commented Oct 2, 2024

close #11956 see #11956 (comment)

Background: #11956 (comment)

#11884 removed internal support for using once: true with watchEffect. While this was never part of the public API, it was being used internally to perform clean-up during SSR.

This potentially leads to watchEffect leaking during SSR, though I believe this would only be a problem in practice if it was watching data that was retained across requests.

Example:

Rather than adding support back into @vue/reactivity, I've tried to implement a fix that will only be included for SSR builds.

I call the stop function immediately after creating the watcher. In the cases we care about, the watcher should have already run by this point.

I've made a big assumption: watchEffect with flush: 'post' should not run during SSR. I don't know whether this assumption is valid, but the approach I've taken here won't work if that isn't correct.

Copy link

github-actions bot commented Oct 2, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB 38.1 kB 34.3 kB
vue.global.prod.js 160 kB 58 kB 51.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49 kB 18.9 kB 17.2 kB
createApp 55.6 kB (+18 B) 21.4 kB (+17 B) 19.5 kB (-70 B)
createSSRApp 59.7 kB (+18 B) 23.1 kB (+13 B) 21 kB (+18 B)
defineCustomElement 60.4 kB (+18 B) 23 kB (+20 B) 21 kB (+81 B)
overall 69.4 kB (+18 B) 26.5 kB (+18 B) 24.1 kB (+30 B)

Copy link

pkg-pr-new bot commented Oct 2, 2024

Open in Stackblitz

@vue/compiler-dom

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

@vue/compiler-core

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

@vue/compiler-ssr

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

@vue/compiler-sfc

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: bfe33d8

@edison1105
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link
Contributor

vue-bot commented Oct 2, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools failure failure
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

@edison1105 edison1105 added ready to merge The PR is ready to be merged. ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. labels Oct 4, 2024
@yyx990803 yyx990803 merged commit b094c72 into vuejs:main Oct 4, 2024
13 checks passed
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vue 3.5.6 memory leaks
4 participants