Skip to content

fix(runtime-core): restore SSR setup state when handling async setup result - #15114

Merged
edison1105 merged 1 commit into
vuejs:mainfrom
cernymatej:fix/ssr-async-setup-watcher-leak
Aug 4, 2026
Merged

fix(runtime-core): restore SSR setup state when handling async setup result#15114
edison1105 merged 1 commit into
vuejs:mainfrom
cernymatej:fix/ssr-async-setup-watcher-leak

Conversation

@cernymatej

@cernymatej cernymatej commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

fix #15113

this should fix a problem where regular watchers were being created on the server for Options API components with async setup()

and also a potential memory leak since SSR never unmounts and such a watcher is never stopped... if it depends on request-outliving state, it retains the whole component instance and through it the whole app

Summary by CodeRabbit

  • Bug Fixes
    • Improved server-side rendering reliability for components using asynchronous setup.
    • Prevented watchers from being created or retained unexpectedly during server-side rendering.
    • Reduced potential memory retention after repeated server-rendered requests.

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

SSR async setup() resolution now preserves SSR setup state while processing results and reliably restores it. Regression tests verify option-API watchers are not created and rendered apps are garbage-collected.

Changes

SSR async setup watcher lifecycle

Layer / File(s) Summary
Preserve SSR setup state during async resolution
packages/runtime-core/src/component.ts
The async setup Promise handler enables SSR setup state while handling the resolved result and disables it in a finally block.
Validate watcher suppression and garbage collection
packages/server-renderer/__tests__/ssrWatch.spec.ts
Regression tests verify that async setup does not create option-API watchers and that rendered apps are released after garbage collection.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • vuejs/core#14547: Both changes preserve SSR setup state across async setup boundaries.

Suggested labels: scope: ssr, :hammer: p3-minor-bug

Suggested reviewers: edison1105

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code and tests address #15113 by preventing SSR watchers from being created and retained for async setup components.
Out of Scope Changes check ✅ Passed The changes stay focused on the SSR async setup watcher leak fix and its regression tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the runtime-core SSR async setup state fix, which is the main code change in the PR.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 31ff39d

@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 107 kB (+25 B) 40.5 kB (+12 B) 36.3 kB (+31 B)
vue.global.prod.js 166 kB (+25 B) 60.6 kB (+12 B) 53.8 kB (+22 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49.2 kB (+27 B) 19.1 kB (+12 B) 17.5 kB (+15 B)
createApp 57.4 kB (+27 B) 22.2 kB (+14 B) 20.3 kB (+13 B)
createSSRApp 61.9 kB (+27 B) 24.1 kB (+18 B) 22 kB (+17 B)
defineCustomElement 63.6 kB (+27 B) 24.1 kB (+14 B) 22 kB (+16 B)
overall 72 kB (+25 B) 27.5 kB (+11 B) 25 kB (+4 B)

@edison1105 edison1105 changed the title fix(runtime-core): avoid leaking Options API watchers in SSR async setup fix(runtime-core): restore SSR setup state when handling async setup result Jul 20, 2026
@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: ssr 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ❗ p4-important Priority 4: this fixes bugs that violate documented behavior, or significantly improves perf. and removed 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Jul 20, 2026
@edison1105

Copy link
Copy Markdown
Member

/ecosystem-ci run

@vue-bot

vue-bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📝 Ran ecosystem CI: Open

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

@vuejs vuejs deleted a comment from edison1105 Aug 4, 2026
@edison1105
edison1105 merged commit b6191cb into vuejs:main Aug 4, 2026
14 checks passed
@cernymatej
cernymatej deleted the fix/ssr-async-setup-watcher-leak branch August 21, 2026 01:19
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: ssr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSR memory leak - options API watchers are created and never stopped with async setup()

3 participants