Repository navigation
fix(runtime-vapor): support render vapor async wrapper in vdom suspense - #14633
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 |
Size ReportBundles
Usages
|
@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: |
There was a problem hiding this comment.
Actionable comments posted: 1
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/components/KeepAlive.ts (1)
181-201:⚠️ Potential issue | 🟠 MajorLate async cache updates still treat the passed block as the live branch.
cacheBlock(block)is now used for offscreen/deactivated async branches, butinnerCacheBlock()still doescurrent = block, and this late-cache path never reapplies the keep-alive shape flags thatprocessShapeFlag()would have set during render. A background resolve can therefore replace the pointer to the real active branch, confuse later max/include/exclude pruning, and still leave a newly cacheable async wrapper on the unmount path on the next switch.🔧 Suggested direction
- const innerCacheBlock = ( - key: CacheKey, - block: VaporComponentInstance | VaporFragment, - ) => { + const innerCacheBlock = ( + key: CacheKey, + block: VaporComponentInstance | VaporFragment, + isCurrent: boolean, + ) => { const { max } = props if (cache.has(key)) { // make this key the freshest keys.delete(key) @@ } cache.set(key, block) - current = block + if (isCurrent) current = block } @@ if (!shouldCache(innerBlock, props, interop)) { if (cache.has(cacheKey)) pruneCacheEntry(cacheKey) return } - innerCacheBlock(cacheKey, innerBlock) + if (interop && isInteropEnabled) { + innerBlock.vnode!.shapeFlag! |= ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE + if (cache.has(cacheKey)) { + innerBlock.vnode!.shapeFlag! |= ShapeFlags.COMPONENT_KEPT_ALIVE + } + } else { + ;(innerBlock as VaporComponentInstance).shapeFlag! |= + ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE + if (cache.has(cacheKey)) { + ;(innerBlock as VaporComponentInstance).shapeFlag! |= + ShapeFlags.COMPONENT_KEPT_ALIVE + } + } + + innerCacheBlock( + cacheKey, + innerBlock, + block === keepAliveInstance.block, + )Also applies to: 203-233
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/runtime-vapor/src/components/KeepAlive.ts` around lines 181 - 201, innerCacheBlock currently sets current = block unconditionally, which lets late async/offscreen cache updates overwrite the active pointer and skip shape-flag processing; update innerCacheBlock (and the similar code in the other block) to: 1) call processShapeFlag(block) before inserting into cache so the keep-alive shape flags are reapplied for late/offscreen branches, and 2) avoid assigning current = block for offscreen/deactivated async wrappers (only set current when the block is the actual active branch). Use the existing symbols cache, keys, cacheBlock, processShapeFlag and pruneCacheEntry to implement the conditional current assignment and flag reappliance so pruning and unmount paths behave correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/runtime-vapor/src/apiDefineAsyncComponent.ts`:
- Around line 180-188: The Suspense error path is unintentionally forwarding the
wrapper's slots into the errorComponent due to defaulting rawSlots to
parent.rawSlots; update the createInnerComp(...) call inside frag.update (the
one that constructs errorComponent) to explicitly pass an empty/new slots object
(or the same slot shape used in the non-Suspense error branch) so the
errorComponent does not receive slot fallthrough; adjust the other similar
createInnerComp(...) invocation(s) that build errorComponent in the suspensible
path to do the same (referencing createInnerComp, errorComponent, frag.update
and rawSlots/parent.rawSlots).
---
Outside diff comments:
In `@packages/runtime-vapor/src/components/KeepAlive.ts`:
- Around line 181-201: innerCacheBlock currently sets current = block
unconditionally, which lets late async/offscreen cache updates overwrite the
active pointer and skip shape-flag processing; update innerCacheBlock (and the
similar code in the other block) to: 1) call processShapeFlag(block) before
inserting into cache so the keep-alive shape flags are reapplied for
late/offscreen branches, and 2) avoid assigning current = block for
offscreen/deactivated async wrappers (only set current when the block is the
actual active branch). Use the existing symbols cache, keys, cacheBlock,
processShapeFlag and pruneCacheEntry to implement the conditional current
assignment and flag reappliance so pruning and unmount paths behave correctly.
🪄 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: 7c32f175-6c9a-46df-91ae-416747fcfff3
📒 Files selected for processing (6)
packages/runtime-vapor/__tests__/components/KeepAlive.spec.tspackages/runtime-vapor/__tests__/vdomInterop.spec.tspackages/runtime-vapor/src/apiDefineAsyncComponent.tspackages/runtime-vapor/src/apiTemplateRef.tspackages/runtime-vapor/src/components/KeepAlive.tspackages/runtime-vapor/src/vdomInterop.ts
3f2c211 to
fb5d72c
Compare
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/components/KeepAlive.ts (1)
471-484:⚠️ Potential issue | 🟠 MajorAlso reset the resolved interop child here.
defineVaporAsyncComponent()can resolve to a VDOM child, but this helper only clears the inner block when it is vapor. If the wrapper is pruned after resolving to an interop fragment,inner.vnode.shapeFlagstill carries the keep-alive bits into teardown.Suggested fix
const unsetShapeFlag = (cached: VaporComponentInstance | VaporFragment) => { if (isVaporComponent(cached)) { resetShapeFlag(cached) // for async components, also reset the inner resolved component's // shapeFlag. if (isAsyncWrapper(cached)) { const [inner] = getInnerBlock(cached.block) - if (inner && isVaporComponent(inner)) { - resetShapeFlag(inner) + if (inner) { + if (isVaporComponent(inner)) { + resetShapeFlag(inner) + } else if (isInteropEnabled) { + resetShapeFlag(inner.vnode) + } } } } else if (isInteropEnabled) { resetShapeFlag(cached.vnode) } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/runtime-vapor/src/components/KeepAlive.ts` around lines 471 - 484, The unsetShapeFlag helper must also clear shape flags on resolved interop children when an async wrapper resolves to a non-vapor (interop) fragment: inside unsetShapeFlag, after obtaining inner via getInnerBlock(cached.block), if inner exists and is not a vapor component but interop is enabled (isInteropEnabled), call resetShapeFlag(inner.vnode) so the vnode's shapeFlag doesn't retain keep-alive bits; keep existing branches for isVaporComponent(inner) and add this additional conditional to handle the interop case.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/runtime-vapor/src/components/KeepAlive.ts`:
- Around line 471-484: The unsetShapeFlag helper must also clear shape flags on
resolved interop children when an async wrapper resolves to a non-vapor
(interop) fragment: inside unsetShapeFlag, after obtaining inner via
getInnerBlock(cached.block), if inner exists and is not a vapor component but
interop is enabled (isInteropEnabled), call resetShapeFlag(inner.vnode) so the
vnode's shapeFlag doesn't retain keep-alive bits; keep existing branches for
isVaporComponent(inner) and add this additional conditional to handle the
interop case.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 76d964c6-f9fe-4c22-9e75-f9e8cf2267c4
📒 Files selected for processing (4)
packages/runtime-vapor/__tests__/components/KeepAlive.spec.tspackages/runtime-vapor/__tests__/vdomInterop.spec.tspackages/runtime-vapor/src/apiDefineAsyncComponent.tspackages/runtime-vapor/src/components/KeepAlive.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/runtime-vapor/src/apiDefineAsyncComponent.ts
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests