Repository navigation
fix(runtime-vapor): restore hmr context on errors - #14908
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/compiler-vapor
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/runtime-vapor
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Size ReportBundles
Usages
|
There was a problem hiding this comment.
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
📒 Files selected for processing (9)
packages/runtime-core/src/hmr.tspackages/runtime-vapor/__tests__/components/Teleport.spec.tspackages/runtime-vapor/__tests__/hmr.spec.tspackages/runtime-vapor/src/block.tspackages/runtime-vapor/src/component.tspackages/runtime-vapor/src/components/KeepAlive.tspackages/runtime-vapor/src/components/Teleport.tspackages/runtime-vapor/src/fragment.tspackages/runtime-vapor/src/hmr.ts
💤 Files with no reviewable changes (1)
- packages/runtime-vapor/src/components/Teleport.ts
There was a problem hiding this comment.
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 winStop newly created render effects when
devRender()fails.If
devRender()throws after registering new entries ininstance.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
📒 Files selected for processing (6)
packages/runtime-core/__tests__/hmr.spec.tspackages/runtime-core/src/hmr.tspackages/runtime-vapor/__tests__/hmr.spec.tspackages/runtime-vapor/src/component.tspackages/runtime-vapor/src/hmr.tspackages/runtime-vapor/src/renderEffect.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/runtime-vapor/src/component.ts
Summary by CodeRabbit
Bug Fixes
Tests
Refactor