-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
fix(nuxt): clear async data after a tick #32096
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
|
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.
Pull Request Overview
This PR fixes a transition bug by deferring the clearing of async data until the next tick.
- Introduces nextTick wrapping to delay async data clearance and avoid breaking transitions during navigation.
@@ -712,8 +712,12 @@ function createAsyncData< | |||
asyncData._init = false | |||
// TODO: disable in v4 in favour of custom caching strategies | |||
if (purgeCachedData && !hasCustomGetCachedData) { |
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.
It would help to add a comment here explaining why the call to nextTick is required, referencing the transition bug and the linked issue for future maintainability.
if (purgeCachedData && !hasCustomGetCachedData) { | |
if (purgeCachedData && !hasCustomGetCachedData) { | |
// Using nextTick to ensure this cleanup logic runs after the current DOM update cycle. | |
// This addresses a known transition bug. See https://github.com/nuxt/nuxt/issues/12345 for details. |
Copilot uses AI. Check for mistakes.
WalkthroughThe import statement in the asyncData composable was updated to include the Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 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 (
|
@nuxt/kit
nuxt
@nuxt/schema
@nuxt/rspack-builder
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #32096 will not alter performanceComparing Summary
|
clearNuxtDataByKey(nuxtApp, key) | ||
asyncData.execute = () => Promise.resolve() | ||
nextTick(() => { | ||
if (!asyncData._init) { |
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.
Hi @danielroe! I guess it was meant to be:
if (!nuxtApp._asyncData[key]?._init) {
I'm not sure, but I don't see any place where _init could be switched from false
to true
. And it seems like there can be a bug if an asyncData is going to be cleared and a new asyncData with the same key is created at this moment.
🔗 Linked issue
resolves #32093
📚 Description
when clearing nuxt data inside a transition this can break the transition totally (likely a vue upstream bug in here that would be worth investigating and reporting)
a workaround is to defer this until the next tick