-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
base: main
Are you sure you want to change the base?
Conversation
because new vnodes may contain async components
WalkthroughThe change removes logic from the Changes
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (4)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
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
close #13453
because new vnodes may contain async components
Summary by CodeRabbit