-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
fix(nuxt): handle non-immediate useAsyncData with different key on ssr
#33341
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
|
|
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
CodSpeed Performance ReportMerging #33341 will not alter performanceComparing Summary
|
WalkthroughChanges in packages/nuxt/src/app/composables/asyncData.ts introduce a lazy-initialisation wrapper Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
⏰ 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). (3)
🔇 Additional comments (2)
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. Comment |
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
🧹 Nitpick comments (1)
packages/nuxt/src/app/composables/asyncData.ts (1)
371-375: Optional: increment deps on lazy creation for parity with key‑watch pathWhen lazily creating a new per‑key instance here (SSR,
immediate: false), consider bumping_depslike the key‑watcher does, to keep lifecycle semantics consistent.if (!nuxtApp._asyncData[key.value]?._init) { const cachedData = options.getCachedData!(key.value, nuxtApp, { cause: 'initial' }) nuxtApp._asyncData[key.value] = createAsyncData(nuxtApp, key.value, _handler, options, cachedData) + nuxtApp._asyncData[key.value]!._deps++ }As per coding guidelines
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/nuxt/src/app/composables/asyncData.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Follow standard TypeScript conventions and best practices
Files:
packages/nuxt/src/app/composables/asyncData.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: Tofandel
PR: nuxt/nuxt#33192
File: test/nuxt/use-async-data.test.ts:366-373
Timestamp: 2025-09-10T14:42:56.647Z
Learning: In the Nuxt useAsyncData test "should watch params deeply in a non synchronous way", the foo watcher intentionally updates both params.foo and params.locale using locale.value, simulating a scenario where one watcher consolidates multiple reactive values into a shared params object for testing debounced/non-synchronous behavior.
🔗 Linked issue
📚 Description
this handles an odd edge case I encountered.
Normally on client-side this works because reactivity has already created the new asyncData instance but on the server this can't be relied on.