WalkthroughThe PR changes theAsyncDataHandler<ResT> signature from two positional parameters(nuxtApp, options: { signal }) to a single context object(context: { signal, nuxtApp }). Call sites in the async data composable, fetch composable and related tests have been updated to pass and destructure this single context object. Abort signal handling remains viacontext.signal. The public type export and documentation examples were updated to reflect the new handler shape. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes - Changes follow a consistent refactor pattern across multiple files (type, composables, tests).
- Review should verify all call sites pass
{ signal, nuxtApp } correctly and thatnuxtApp is extracted where needed (prerender/cache logic inasyncData.ts). - Confirm exported
AsyncDataHandler type and documentation examples are updated and consistent.
Pre-merge checks and finishing touches❌ Failed checks (1 warning)| Check name | Status | Explanation | Resolution |
|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run@coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (4 passed)| Check name | Status | Explanation |
|---|
| Title Check | ✅ Passed | The pull request title "feat!: simplifyuseAsyncData() handler signature" is clear, concise, and directly related to the main change in the changeset. The title accurately captures the primary objective of refactoring the AsyncDataHandler signature from separate parameters to a single context object. It follows conventional commits format with the breaking change indicator (!), and avoids vague terminology or excessive detail. A developer scanning the history would immediately understand that this PR simplifies the useAsyncData handler interface. | | Linked Issues Check | ✅ Passed | The code changes fully implement the objective specified in linked issue#33623. The AsyncDataHandler type signature has been updated from(nuxtApp: NuxtApp, options: { signal: AbortSignal }) to(context: { signal: AbortSignal, nuxtApp: NuxtApp }) across all relevant files. All internal call sites in asyncData.ts and fetch.ts have been updated to pass the new context object format, documentation examples have been revised, and tests have been updated accordingly. The implementation directly addresses the issue's requirement to simplify the handler signature by consolidating parameters into a single object. | | Out of Scope Changes Check | ✅ Passed | All code changes are directly scoped to the objective of simplifying the AsyncDataHandler signature. The modifications span documentation (use-async-data.md), implementation files (asyncData.ts and fetch.ts), and tests (use-async-data.test.ts), with every change either updating the handler signature itself, adapting call sites to the new signature, or updating documentation and tests to reflect the change. No extraneous modifications or tangential improvements are present in the changeset. | | Description Check | ✅ Passed | The pull request description is related to the changeset, stating that it "simplifies the usage foruseAsyncData handlers" and linking to the relevant issue#33623. Whilst minimal in detail, the description appropriately captures the intent of the changes and provides the necessary context linking to the GitHub issue. The description meets the lenient pass criteria for this check as it is clearly on-topic and describes a genuine aspect of the changeset. |
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📥 CommitsReviewing files that changed from the base of the PR and between911b3cf and2e570fc. 📒 Files selected for processing (4)docs/3.api/2.composables/use-async-data.md (7 hunks)packages/nuxt/src/app/composables/asyncData.ts (3 hunks)packages/nuxt/src/app/composables/fetch.ts (1 hunks)test/nuxt/use-async-data.test.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)- packages/nuxt/src/app/composables/fetch.ts
- docs/3.api/2.composables/use-async-data.md
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md) Follow standard TypeScript conventions and best practices
Files: test/nuxt/use-async-data.test.tspackages/nuxt/src/app/composables/asyncData.ts
**/*.{test,spec}.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md) Write unit tests for core functionality usingvitest
Files: test/nuxt/use-async-data.test.ts
🧠 Learnings (1)📚 Learning: 2025-09-10T14:42:56.647ZLearnt from: TofandelRepo: nuxt/nuxt PR: 33192File: test/nuxt/use-async-data.test.ts:366-373Timestamp: 2025-09-10T14:42:56.647ZLearning: 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.
Applied to files: test/nuxt/use-async-data.test.tspackages/nuxt/src/app/composables/asyncData.ts
🧬 Code graph analysis (1)packages/nuxt/src/app/composables/asyncData.ts (1)packages/nuxt/src/app/nuxt.ts (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). (2)- GitHub Check: build
- GitHub Check: code
🔇 Additional comments (7)test/nuxt/use-async-data.test.ts (4)955-969:LGTM: Handler signature correctly updated.
The test properly validates that the handler receives the signal in the context object and that it can be aborted viaclear().
1002-1027:LGTM: Signal merging test properly updated.
The handler correctly destructures the signal from the context object. The test validates that multiple abort signals can be merged, which is important for external cancellation scenarios.
1084-1104:LGTM: Dedupe cancellation with abort properly tested.
The handler correctly receives and uses the signal from the context object. The test validates that the first request is properly aborted whendedupe: 'cancel' is used.
1136-1155:LGTM: Clear abort behaviour correctly validated.
The handler properly destructures the signal from the context object and the test confirms that callingclear() triggers the abort signal, setting the status to idle.
packages/nuxt/src/app/composables/asyncData.ts (3)20-20:Breaking change: Handler signature simplified.
The new signature consolidatesnuxtApp and the options object into a single context parameter, which aligns with the PR objectives to simplify the handler signature and facilitate signal integration.
651-662:LGTM: Prerender wrapper correctly updated.
The wrapper properly adapts to the new signature by accepting a singlectx parameter, destructuringnuxtApp for cache operations, and forwarding the complete context (includingsignal) to the underlying handler.
707-726:LGTM: Handler invocation correctly updated.
The handler is properly invoked with a single context object containing bothsignal (with merged abort signals including timeout) andnuxtApp. The implementation correctly handles abort scenarios before and during execution.
Thanks for usingCodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment@coderabbitai help to get the list of available commands and usage tips. |
Caution
Breaking change
🔗 Linked issue
fixes#33623
📚 Description
This simplifies the usage for
useAsyncDatahandlers.