Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(ssr): avoid triggering onScopeDispose during SSR cleanup#14673

Closed
edison1105 wants to merge 1 commit into
mainfrom
edison/fix/14669
Closed

fix(ssr): avoid triggering onScopeDispose during SSR cleanup#14673
edison1105 wants to merge 1 commit into
mainfrom
edison/fix/14669

Conversation

@edison1105

@edison1105 edison1105 commented Apr 3, 2026

Copy link
Copy Markdown
Member

close #14669

Summary by CodeRabbit

  • Bug Fixes

    • Fixed server-side rendering cleanup to prevent unintended user cleanup callback execution during scope disposal.
  • Refactor

    • Enhanced effect scope disposal with more granular control over cleanup callback invocation, allowing selective suppression of cleanup execution during parent-child scope termination.

@coderabbitai

coderabbitai Bot commented Apr 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 36bfe01a-39bb-42b5-b08e-ee04b6741241

📥 Commits

Reviewing files that changed from the base of the PR and between fa23116 and 4766fe4.

📒 Files selected for processing (3)
  • packages/reactivity/src/effectScope.ts
  • packages/server-renderer/__tests__/render.spec.ts
  • packages/server-renderer/src/render.ts

📝 Walkthrough

Walkthrough

Added an optional allowScopeCleanups parameter to EffectScope.stop() to control cleanup callback execution. Updated server-renderer to call stop(false, false) when disposing component scopes, preventing onScopeDispose callbacks from running during SSR.

Changes

Cohort / File(s) Summary
Effect Scope Cleanup Control
packages/reactivity/src/effectScope.ts
Updated EffectScope.stop() signature to accept optional allowScopeCleanups parameter (default true). Cleanup callbacks in this.cleanups now execute conditionally based on this parameter. Child scopes are stopped with propagated allowScopeCleanups value instead of always true.
SSR Cleanup Behavior
packages/server-renderer/src/render.ts, packages/server-renderer/__tests__/render.spec.ts
Updated SSRContext.__instanceScopes type signature to reflect new EffectScope.stop parameters. Modified cleanupContext() to invoke scope.stop(false, false) to suppress onScopeDispose callbacks during SSR. Tests updated to verify no cleanup callbacks execute during scope disposal.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ready to merge, scope: ssr, scope: reactivity, :hammer: p3-minor-bug

Poem

🐰 Scopes now choose what to clean,
SSR whispers soft and lean—
No callbacks cry when servers rest,
Cleanup flows where it's best! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: preventing onScopeDispose from being triggered during SSR cleanup, which is the core objective.
Linked Issues check ✅ Passed The PR successfully implements the requirement from issue #14669 by adding an allowScopeCleanups parameter to control cleanup execution, preventing onScopeDispose from running during SSR.
Out of Scope Changes check ✅ Passed All changes are focused on implementing the SSR cleanup fix: updating EffectScope.stop signature, modifying SSR cleanup to pass allowScopeCleanups=false, and updating related tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch edison/fix/14669

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

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 105 kB (+12 B) 39.8 kB (+10 B) 35.8 kB (+18 B)
vue.global.prod.js 164 kB (+12 B) 59.8 kB (+9 B) 53.2 kB (-12 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.3 kB (+12 B) 18.8 kB (+7 B) 17.2 kB (+8 B)
createApp 56.5 kB (+12 B) 21.8 kB (+6 B) 20 kB (+6 B)
createSSRApp 60.7 kB (+12 B) 23.6 kB (+8 B) 21.5 kB (+9 B)
defineCustomElement 62.7 kB (+12 B) 23.8 kB (+7 B) 21.7 kB (+10 B)
overall 71 kB (+12 B) 27.2 kB (+6 B) 24.8 kB (+62 B)

@pkg-pr-new

pkg-pr-new Bot commented Apr 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@14673
npm i https://pkg.pr.new/@vue/compiler-core@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@14673
npm i https://pkg.pr.new/@vue/compiler-dom@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@14673
npm i https://pkg.pr.new/@vue/compiler-sfc@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@14673
npm i https://pkg.pr.new/@vue/compiler-ssr@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@14673
npm i https://pkg.pr.new/@vue/reactivity@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@14673
npm i https://pkg.pr.new/@vue/runtime-core@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@14673
npm i https://pkg.pr.new/@vue/runtime-dom@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@14673
npm i https://pkg.pr.new/@vue/server-renderer@14673
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@14673
npm i https://pkg.pr.new/@vue/shared@14673
yarn add https://pkg.pr.new/@vue/[email protected]

vue

pnpm add https://pkg.pr.new/vue@14673
npm i https://pkg.pr.new/vue@14673
yarn add https://pkg.pr.new/[email protected]

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@14673
npm i https://pkg.pr.new/@vue/compat@14673
yarn add https://pkg.pr.new/@vue/[email protected]

commit: 4766fe4

@edison1105 edison1105 closed this Apr 3, 2026
@edison1105 edison1105 deleted the edison/fix/14669 branch June 9, 2026 02:16
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.

onScopeDispose is triggered on SSR

1 participant