Skip to content

fix(runtime-vapor): restore hmr context on errors - #14908

Merged
edison1105 merged 7 commits into
minorfrom
edison/fix/hmrBugs
Jun 3, 2026
Merged

edison1105 merged 7 commits into
minorfrom
edison/fix/hmrBugs

Conversation

@edison1105

@edison1105 edison1105 commented Jun 2, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved HMR reload behavior with optimized parent rerendering to avoid redundant updates.
    • Enhanced instance state restoration and cleanup during HMR failures.
  • Tests

    • Added comprehensive HMR test coverage including vapor/vdom component scenarios and error-handling cases.
  • Refactor

    • Internal restructuring of component instance tracking and block boundary handling for improved clarity.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

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: Pro

Run ID: 29a2701d-459d-48c2-9751-712de2a46ed9

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:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch edison/fix/hmrBugs

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

@pkg-pr-new

pkg-pr-new Bot commented Jun 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-vapor

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 27cf9f3

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 86.5 kB 30.3 kB 26.6 kB
runtime-dom.global.prod.js 113 kB 42.6 kB 38.2 kB
vue.global.prod.js 173 kB 62.4 kB 55.7 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 51.6 kB 20.1 kB 18.4 kB
createApp 60.6 kB 23.5 kB 21.3 kB
createApp + vaporInteropPlugin 107 kB 38.5 kB 34.7 kB
createVaporApp 30.1 kB 11.5 kB 10.6 kB
createSSRApp 65.2 kB 25.3 kB 23 kB
createVaporSSRApp 36.5 kB 13.8 kB 12.7 kB
defineCustomElement 67.2 kB 25.5 kB 23.1 kB
defineVaporCustomElement 41.4 kB 14.8 kB 13.6 kB
overall 75.9 kB 28.9 kB 26.2 kB

@edison1105 edison1105 added the scope: vapor related to vapor mode label Jun 2, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/runtime-core/src/hmr.ts`:
- Around line 146-151: The fallback in reload() currently enqueues a queueJob
per dirty instance (checking instance.parent and ceReload) which creates
distinct inline callbacks so queueJob deduplication fails; change the logic to
collect unique parent nodes (e.g., new Set over instance.parent for instances
that have parent and !instance.parent.vapor and !i.ceReload and newComp.__vapor)
and then call queueJob once per unique parent to ensure only one rerender job is
queued per parent; reference reload(), instances, instance.parent, ceReload,
queueJob(), and newComp.__vapor when making the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3d9f599a-9364-4fe8-b27c-5de19665415e

📥 Commits

Reviewing files that changed from the base of the PR and between db712e2 and e634f97.

📒 Files selected for processing (9)
  • packages/runtime-core/src/hmr.ts
  • packages/runtime-vapor/__tests__/components/Teleport.spec.ts
  • packages/runtime-vapor/__tests__/hmr.spec.ts
  • packages/runtime-vapor/src/block.ts
  • packages/runtime-vapor/src/component.ts
  • packages/runtime-vapor/src/components/KeepAlive.ts
  • packages/runtime-vapor/src/components/Teleport.ts
  • packages/runtime-vapor/src/fragment.ts
  • packages/runtime-vapor/src/hmr.ts
💤 Files with no reviewable changes (1)
  • packages/runtime-vapor/src/components/Teleport.ts

Comment thread packages/runtime-core/src/hmr.ts Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/runtime-vapor/src/hmr.ts (1)

26-31: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Stop newly created render effects when devRender() fails.

If devRender() throws after registering new entries in instance.renderEffects, those effects stay live even though the old block was already removed and the new block was never inserted. Please clear the newly created effects on the error path before rethrowing.

💡 Proposed fix
   try {
     devRender(instance)
+  } catch (err) {
+    if (instance.renderEffects) {
+      instance.renderEffects.forEach(e => e.stop())
+      instance.renderEffects.length = 0
+    }
+    throw err
   } finally {
     popWarningContext()
     setCurrentInstance(...prev)
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/runtime-vapor/src/hmr.ts` around lines 26 - 31, Before calling
devRender(instance), snapshot the current renderEffects (e.g., record
prevEffects = instance.renderEffects.slice() or prevLen =
instance.renderEffects.length). Wrap devRender in try/catch so that if it throws
you iterate any newly added effects (those beyond prevLen or not in
prevEffects), call their stop/cleanup method and remove them from
instance.renderEffects, then rethrow the error; keep the existing finally that
calls popWarningContext() and setCurrentInstance(...prev). This ensures
devRender's partially-registered effects are stopped and removed on the error
path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/runtime-vapor/src/hmr.ts`:
- Around line 26-31: Before calling devRender(instance), snapshot the current
renderEffects (e.g., record prevEffects = instance.renderEffects.slice() or
prevLen = instance.renderEffects.length). Wrap devRender in try/catch so that if
it throws you iterate any newly added effects (those beyond prevLen or not in
prevEffects), call their stop/cleanup method and remove them from
instance.renderEffects, then rethrow the error; keep the existing finally that
calls popWarningContext() and setCurrentInstance(...prev). This ensures
devRender's partially-registered effects are stopped and removed on the error
path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff888637-5ac3-4cd3-b81e-a0955633c420

📥 Commits

Reviewing files that changed from the base of the PR and between e634f97 and 27cf9f3.

📒 Files selected for processing (6)
  • packages/runtime-core/__tests__/hmr.spec.ts
  • packages/runtime-core/src/hmr.ts
  • packages/runtime-vapor/__tests__/hmr.spec.ts
  • packages/runtime-vapor/src/component.ts
  • packages/runtime-vapor/src/hmr.ts
  • packages/runtime-vapor/src/renderEffect.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime-vapor/src/component.ts

@edison1105
edison1105 marked this pull request as ready for review June 3, 2026 05:50
@edison1105
edison1105 merged commit 9a7c040 into minor Jun 3, 2026
14 checks passed
@edison1105
edison1105 deleted the edison/fix/hmrBugs branch June 3, 2026 05:50
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.

1 participant