-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
fix(suspense): don't immediately resolve suspense on last dep unmount #13456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
because new vnodes may contain async components
WalkthroughRemoved legacy logic in unmountComponent that decremented a parent Suspense's pending deps and possibly resolved the boundary during unmount; added a test that exercises adding/removing async deps during Suspense patching. No public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Unmount as unmountComponent
participant Suspense as ParentSuspense
participant AsyncComp as AsyncComponent
rect rgb(240,248,255)
note right of Unmount: Old flow (before change)
AsyncComp->>Unmount: unmount (unresolved)
Unmount->>Suspense: decrement deps
Suspense->>Suspense: if deps == 0 -> resolve()
Suspense-->>AsyncComp: resolve/cleanup
end
rect rgb(255,250,240)
note right of Unmount: New flow (after change)
AsyncComp->>Unmount: unmount (unresolved)
Unmount-->>AsyncComp: cleanup (no parent deps change)
Suspense->>Suspense: resolution occurs only when async resolves or other existing paths trigger it
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Out-of-scope changes(No out-of-scope changes detected.) Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/runtime-core/__tests__/components/Suspense.spec.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
- GitHub Check: test / unit-test-windows
🔇 Additional comments (2)
packages/runtime-core/__tests__/components/Suspense.spec.ts (2)
20-21
: LGTM: Import additions are correct.The
renderList
andrenderSlot
imports are properly added and necessary for the new test case implementation.
2167-2241
: Well-designed test for dynamic async dependency management.This test effectively validates the fix for issue #13453 by simulating the scenario where:
- New async dependencies are added during Suspense patching
- Existing dependencies are removed
- The Suspense boundary correctly handles the transition without prematurely resolving
The test logic properly covers the edge case mentioned in the PR objectives where new vnodes may contain async components during the unmounting process.
const getComponent = (type: string) => { | ||
if (type === 'A') { | ||
return defineAsyncComponent({ | ||
name: 'A', | ||
setup() { | ||
return () => h('div', 'A') | ||
}, | ||
}) | ||
} | ||
return defineAsyncComponent({ | ||
name: 'A', | ||
setup() { | ||
return () => h('div', 'B') | ||
}, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the component name inconsistency.
The second branch of getComponent
should return a component with name: 'B'
instead of name: 'A'
to maintain consistency and avoid confusion during debugging.
return defineAsyncComponent({
- name: 'A',
+ name: 'B',
setup() {
return () => h('div', 'B')
},
})
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const getComponent = (type: string) => { | |
if (type === 'A') { | |
return defineAsyncComponent({ | |
name: 'A', | |
setup() { | |
return () => h('div', 'A') | |
}, | |
}) | |
} | |
return defineAsyncComponent({ | |
name: 'A', | |
setup() { | |
return () => h('div', 'B') | |
}, | |
}) | |
} | |
const getComponent = (type: string) => { | |
if (type === 'A') { | |
return defineAsyncComponent({ | |
name: 'A', | |
setup() { | |
return () => h('div', 'A') | |
}, | |
}) | |
} | |
return defineAsyncComponent({ | |
name: 'B', | |
setup() { | |
return () => h('div', 'B') | |
}, | |
}) | |
} |
🤖 Prompt for AI Agents
In packages/runtime-core/__tests__/components/Suspense.spec.ts between lines
2168 and 2183, the getComponent function returns a component with name 'A' in
both branches, causing inconsistency. Update the second branch to return a
component with name 'B' instead of 'A' to ensure the component names correctly
reflect their types and improve clarity during debugging.
8932f3f
to
d88b2f4
Compare
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
close #13453
because new vnodes may contain async components
Summary by CodeRabbit