Repository navigation
documentation in the Fetching Data menu, under the Parallel data fetching section #97739
Replies: 6 comments 4 replies
This comment was marked as low quality.
This comment was marked as low quality.
|
I hear you here. I do believe this part addresses what you are saying, it is just cut in the middle by the snippet no? The entire section is already trying to make this distinction from the start: parallel data fetching means requests are eagerly initiated and start at the same time. It then contrasts that with the sequential example , where So when we follow that example with:
I read that as the callback to the section’s definition of parallel fetching: initiate both requests before awaiting either of them. I'll consider an edit at some point, because I can see how making that transition more explicit could improve the flow, especially since the code sample sits between the explanation and the solution, but I’m not sure the underlying explanation is actually missing today. |
|
Agree with @gilangabdian that the jump after the sequential snippet can feel abrupt, and with @icyJoseph that the idea is already in the section — it’s mainly a transition issue. Right now the flow is:
That third line is correct, but it doesn’t explicitly say “here’s how you fix the example above,” so newcomers can miss the link. A small bridge sentence would help a lot. Something like:
Then keep the existing parallel code sample. Even shorter alternative:
So: yes, worth a small docs tweak for clearer flow; the underlying explanation isn’t wrong. Happy to open a docs PR with that wording if helpful. |
|
Yes, your suggested wording is much clearer and definitely addresses a common point of confusion. The key distinction that trips developers up in React Server Components is initiating the promise vs awaiting the promise:
Your proposed explanation:
...explicitly articulates why sequential happens and how promise initiation works before resolution. Since the Next.js documentation is open source right in this repository, you should definitely submit a quick PR updating the markdown file under |
|
I agree with you — I checked the actual docs page (Getting Started → Fetching Data), and the structure is: the Sequential Fetching section shows the Playlists waiting on Artist example first, then the Parallel section immediately opens with "Start multiple requests by calling fetch, then await them with Promise.all." That sentence is accurate on its own, but it doesn't explicitly draw the causal line back to the problem the previous section just demonstrated — a reader skimming (rather than reading top to bottom) can miss that the parallel section is the fix for the exact sequential pattern shown right above it. Your proposed rewrite is a real improvement because it names the specific cause ("getAlbums doesn't start until getArtist has finished") rather than leaving the reader to infer it, and it makes the fix ("start both requests before awaiting either one") the load-bearing sentence instead of jumping straight to the Promise.all syntax. That said, I'd suggest one small tweak: the docs' own code example actually uses getArtist/getAlbums as the parallel example and getArtist/getArtistPlaylists (via artistID prop dependency) as the sequential one — they're not literally the same two functions across both sections, so your wording might want to say "the previous example" more generically rather than naming getAlbums specifically, to avoid implying it's the same function object being referenced. Since this is a docs wording improvement with a concrete before/after, it'd likely move faster as a PR than as an open-ended discussion — the "Edit this page" link at the bottom of the docs page opens a PR directly against the source markdown in this repo, and doc-wording PRs tend to get reviewed quickly since they're low-risk. Worth linking this discussion in the PR description for context. |
|
Thanks for bringing this up in documentation in the Fetching Data menu, under the Parallel data fetching section. I am following this discussion and looking into the details. Happy to help test or contribute to this area! |
Uh oh!
There was an error while loading. Please reload this page.
Summary
I read the documentation in the Fetching Data menu, Parallel data fetching section, then I felt like the sentence:
"Start multiple requests by calling
fetch, then await them withPromise.all. Requests begin as soon asfetchis called."does not explicitly explain:
"OK, in the example above it can be seen that multiple
async/awaitrequests have a sequential effect. So how do we make it parallel code?"The point here is that I feel like there's a missing sentence. Do you feel the same?
Therefore, I thought it would be better if it were like this:
"In the example above, the requests are sequential because
getAlbumsdoesn't start untilgetArtisthas finished. To fetch them in parallel, start both requests before awaiting either one. You can then usePromise.allto wait for both requests to complete."and then show the code.
So, do you agree that the parts I mentioned above need to be updated?
Additional information
No response
Example
No response
All reactions