Skip to content

fix(runtime-vapor): unmount KeepAlive component reactivated in a nested branch - #15526

Merged
edison1105 merged 2 commits into
vuejs:minorfrom
ValentinYoushkevich:fix/vapor-keepalive-nested-reactivate
Sep 16, 2026
Merged

edison1105 merged 2 commits into
vuejs:minorfrom
ValentinYoushkevich:fix/vapor-keepalive-nested-reactivate

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

A component cached by KeepAlive and re-activated in a nested branch is never unmounted when an enclosing element goes away:

<div v-if="show">
  <KeepAlive>
    <A v-if="view === 'a'" />
    <B v-else-if="view === 'b'" />
    <C v-else />
  </KeepAlive>
</div>

Switching b → c → b, then show = false leaves B mounted: no onUnmounted, and its effects keep running. VDOM unmounts it.

The v-else-if chain is a nested branch, so switching away stops its scope, and the unmount registered there is skipped because B is kept alive. Re-entering returns the cached instance without registering it again. Now the branch scope re-entering a cached component registers its unmount, once per scope.

@coderabbitai

coderabbitai Bot commented Sep 15, 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

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f8fe53e8-7c77-4d53-81a3-704f05f96837

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

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 Sep 15, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-vapor

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 8b9196c

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 87.2 kB 30.6 kB 26.9 kB
runtime-dom.global.prod.js 116 kB 43.7 kB 39.1 kB
vue.global.prod.js 176 kB 63.9 kB 56.8 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 53.2 kB 20.6 kB 18.8 kB
createApp 61.9 kB 23.8 kB 21.7 kB
createApp + vaporInteropPlugin 120 kB (+177 B) 43.3 kB (+53 B) 39 kB (+36 B)
createVaporApp 30.7 kB (+91 B) 11.8 kB (+23 B) 10.8 kB (+33 B)
createSSRApp 67.1 kB 25.9 kB 23.5 kB
createVaporSSRApp 36.9 kB (+91 B) 14 kB (+19 B) 12.9 kB (+32 B)
defineCustomElement 68.5 kB 25.8 kB 23.5 kB
defineVaporCustomElement 46.1 kB (+91 B) 16.8 kB (+20 B) 15.4 kB (-13 B)
overall 77.3 kB 29.4 kB 26.6 kB

@edison1105 edison1105 added the scope: vapor related to vapor mode label Sep 16, 2026
…ed branch

A nested branch teardown stops the scope that registered the cached
component's unmount, and re-entering the branch returned the cached
instance without registering it again, so it never unmounted when an
enclosing element was removed.
@edison1105
edison1105 force-pushed the fix/vapor-keepalive-nested-reactivate branch 2 times, most recently from 510b0c8 to e5bc95d Compare September 16, 2026 03:06
@edison1105
edison1105 merged commit ed35682 into vuejs:minor Sep 16, 2026
20 of 21 checks passed
@ValentinYoushkevich
ValentinYoushkevich deleted the fix/vapor-keepalive-nested-reactivate branch September 17, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: vapor related to vapor mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants