react-doctor/server-sequential-independent-await
Wrap independent awaits in `Promise.all([...])` so they race instead of waterfalling — second call doesn't depend on the first
- Category: Server
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: always
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Rule scans the top-level statements of every async function (declaration, expression, arrow) for two consecutive VariableDeclaration statements where each starts with an await expression and the second declaration reads no identifier introduced by the first. The two calls are independent and waterfall today. Confirm no hidden ordering constraint exists — rate limits, transactional ordering, or side effects on a shared resource can break parallelization.
Fix prompt
Use this once validation confirms the diagnostic is real.
Race the calls with Promise.all: const [user, posts] = await Promise.all([fetchUser(id), fetchPosts(id)]). Use Promise.allSettled when you need partial failure tolerance instead of fail-fast. Latency drops from the sum of both calls to the max. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
Related rules
More Server rules from the rules reference:
react-doctor/server-after-nonblocking: `import { after } from 'next/server'` then wrap: `after(() => analytics.track(...))` — response isn't blockedreact-doctor/server-auth-actions: Add `const session = await auth()` at the top and throw/redirect if unauthorized before any data accessreact-doctor/server-cache-with-object-literal: Pass primitives to React.cache()-wrapped functions — argument identity (not deep equality) is the dedup key, so a fresh `{}` per render bypasses the cachereact-doctor/server-dedup-props: Pass the source array once and derive the projection on the client — passing both doubles RSC serialization bytesreact-doctor/server-fetch-without-revalidate: Pass `{ next: { revalidate: <seconds> } }` (or `cache: "no-store"` / `next: { tags: [...] }`) so stale cached data doesn't silently persist