next.js
d54a8cb3 - docs: correct io() prefetch behavior vs connection() (#101031)

Commit
3 days ago
docs: correct io() prefetch behavior vs connection() (#101031) ## Summary The `io()` reference said `connection()` blocks prefetches while `io()` does not. Outside a cache scope they behave the same: `io()` returns a hanging promise in `prerender`, `prerender-client`, and `prerender-runtime`, like `connection()`, so the code after it is excluded from build-time prerenders and from prefetches. The actual difference is that `io()` resolves inside `"use cache"` scopes (and works in Client Components), while `connection()` throws there. - `io.mdx`: rewrite "How `io()` differs from `connection()`" around the cache-scope difference. - `connection.mdx`: fix the Good to know bullet that said `io()` "can also be cached and prefetched". - `errors/blocking-prerender-{crypto,current-time,random}.mdx`: drop "`io()` does not block prefetches". ## Verification Manual, with a production build of 16.5.0-canary.27 and a Playwright probe that held navigation requests so only prefetched data could render: - With `partialPrefetching: true`, content after `await io()` outside a cache scope is not prefetched (fallback shows), same as `connection()`. A runtime prefetch on a route that reads `cookies()` still stops at `io()`. - A helper that calls `io()` produces a fresh value per request in uncached code and a build-time value (static route) when called from a `"use cache"` function. The `connection()` equivalent fails the build. <!-- NEXT_JS_LLM -->
Author
Parents
Loading