Independent awaits in sequence

next/sequential-awaitwarningperformancenextjs-16

Why it matters

Each await waits for the previous one even though it doesn't use its result: the latencies add up (a waterfall) on every request.

Fix

Start both, then await together: const [a, b] = await Promise.all([readA(), readB()]).

Credit

  • From Vercel

    The react-best-practices skill ranks eliminating async waterfalls with Promise.all as its top-impact rule.

  • From Shu Ding

    Author of better-all, a Promise.all variant that starts each dependent task at the earliest possible moment.

References

See it