Skip to content

Use Promise.all whenever possible #3319

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

Merged
merged 3 commits into from
Jun 14, 2025
Merged

Use Promise.all whenever possible #3319

merged 3 commits into from
Jun 14, 2025

Conversation

conico974
Copy link
Contributor

This should decrease TTFB for page that needs to be generated

Close RND-7316

Copy link

linear bot commented Jun 13, 2025

Copy link

changeset-bot bot commented Jun 13, 2025

⚠️ No Changeset found

Latest commit: a875bb2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

argos-ci bot commented Jun 13, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v1 (Inspect) ✅ No changes detected - Jun 13, 2025, 5:19 PM
customers-v2 (Inspect) ✅ No changes detected - Jun 13, 2025, 5:20 PM
default (Inspect) ✅ No changes detected - Jun 13, 2025, 5:21 PM
v2-cloudflare (Inspect) 👍 Changes approved 7 changed Jun 13, 2025, 5:24 PM
v2-vercel (Inspect) ✅ No changes detected - Jun 13, 2025, 5:23 PM

Copy link
Member

@SamyPesse SamyPesse left a comment

Choose a reason for hiding this comment

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

It makes sense, but I don't think it'll have much impact, I think we should look more at how Next.js process components rendered as siblings that are suspending: is it serial or parallel?

@conico974
Copy link
Contributor Author

It makes sense, but I don't think it'll have much impact, I think we should look more at how Next.js process components rendered as siblings that are suspending: is it serial or parallel?

Totally agree, it's just the first step. But in some cases it could still save a couple hundreds of milliseconds, that's an easy win.

One suspended component will not render it's children before actually reaching the JSX component. For some nested deep in multiple <Suspense />, we have to wait a lot of time before starting to fetch even though we could fetch it right away.

I'm working on a PR that will prefetch things ASAP in the component tree (basically in the layout/page), and we then use these prefetched data instead of fetching them directly in the component.
The ultimate step would probably be to try to get all the necessary data in one single API call (or as few as possible)

@conico974 conico974 merged commit 8721806 into main Jun 14, 2025
21 checks passed
@conico974 conico974 deleted the gbo/await-promise branch June 14, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants