Question presented to candidate: "You have Suspense boundaries and the page still loads slowly, one section at a time. What is going wrong?"
What a strong answer should cover:
- A waterfall is requests running in sequence when they could overlap. Suspense does not cause it, but it makes it easy to write and easy to miss.
- The mechanism: a component suspends, so its children never render, so their requests never start until the parent's resolves.
use()reads a promise; it does not create or cache one. A promise created during render restarts on every render attempt and can suspend forever.- The fix is render-as-you-fetch: start the requests before or while rendering, and pass the promises down — rather than fetch-on-render, where each level begins only after the one above finished.
Promise.allfor independent requests within one component.- Separate Suspense boundaries so an independent slow section does not delay a fast one.
- A genuine dependency — you need the user before you can fetch their orders — cannot be parallelised; contain it behind its own boundary instead.
- Framework loaders and Server Components exist largely to hoist fetching above rendering.
Clarifying questions expected:
- "Are these requests genuinely dependent, or just written sequentially?"
- "Where are the promises created — during render, or before it?"
Code / implementation expected: Yes — the sequential version and the hoisted version, with timings.