Skip to content

Conversation

@martinszeltins
Copy link
Contributor

📚 Description

This PR adds a small section about how to avoid waterfall effect when you need to do multiple API calls. The suggestion is to use Promise.all to fetch in parallel to improve performance.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@coderabbitai
Copy link

coderabbitai bot commented Dec 4, 2025

Walkthrough

The change adds documentation to the performance best practices guide. Specifically, it includes a code example demonstrating how to execute multiple API calls concurrently using Promise.all within useAsyncData, as an alternative to sequential request patterns. The documentation shows the implementation approach for parallel requests. No functional code changes or error-handling modifications are made. No public declarations are altered.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change, which is adding documentation about parallel data fetching in the best practices section.
Description check ✅ Passed The description clearly relates to the changeset, explaining the purpose of adding guidance on using Promise.all to avoid waterfall effects in API calls.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

✨ Issue Enrichment is now available for GitHub issues!

CodeRabbit can now help you manage issues more effectively:

  • Duplicate Detection — Identify similar or duplicate issues
  • Related Issues & PRs — Find relevant issues and PR's from your repository
  • Suggested Assignees — Find the best person to work on the issue
  • Implementation Planning — Generate detailed coding plans for engineers and agents
Disable automatic issue enrichment

To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

issue_enrichment:
  auto_enrich:
    enabled: false

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
docs/3.guide/2.best-practices/performance.md (2)

115-124: Consider showing how to destructure or access the returned data.

The example returns an array from Promise.all, so data will contain [products, shoes]. For clarity, you might want to show destructuring or accessing individual results:

const { data } = await useAsyncData(() => {
  return Promise.all([
    $fetch("/api/products/"),
    $fetch("/api/category/shoes")
  ]);
});

// data will be [productsArray, shoesArray]
// Or destructure: const [products, shoes] = data.value

This helps readers understand the structure of the returned data immediately.


115-124: Document error-handling expectations for Promise.all.

While the example is correct, it's worth noting in the surrounding prose (or as an inline comment) that if any API call rejects, the entire Promise.all fails. For production code, consider mentioning alternatives like Promise.allSettled when partial failures are acceptable.

This addition strengthens the "best practices" aspect of the guide without complicating the basic example.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2a91221 and 9af5573.

📒 Files selected for processing (1)
  • docs/3.guide/2.best-practices/performance.md (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-10T14:42:56.647Z
Learnt from: Tofandel
Repo: nuxt/nuxt PR: 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.

Applied to files:

  • docs/3.guide/2.best-practices/performance.md
🪛 LanguageTool
docs/3.guide/2.best-practices/performance.md

[uncategorized] ~125-~125: Loose punctuation mark.
Context: ..."/api/category/shoes") ]); }); ``` :read-more{title="Data fetching" to="/doc...

(UNLIKELY_OPENING_PUNCTUATION)

🔇 Additional comments (1)
docs/3.guide/2.best-practices/performance.md (1)

115-124: Code pattern is sound and well-placed.

The Promise.all pattern is the correct idiomatic approach for parallel requests in Nuxt, and the placement immediately after the useFetch/useAsyncData explanation makes logical sense. The example is practical and concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant