next.js
553f2b6b - [Cache Components] correctly label IO promises in devtools (#84928)

Commit
183 days ago
[Cache Components] correctly label IO promises in devtools (#84928) Updates to staged rendering (cacheComponents dev) to support "suspended by" in Suspense Devtools - promises for `cookies()` and other user-callable APIs are now created before we start the render. Each call to `cookies()` will return the same promise (although currently it's wrapped in a fresh proxy). The promise is created via `new Promise`, triggered by a timeout (for the relevant stage) and has `displayName`. This marks it as an IO operation. By re-using the same promise, we make sure that all callsites that await it are considered to be suspended by the same IO operation. - promises for `params` and `searchParams` use a similar trick. All instances of `params` and will be derived from one shared IO promise `sharedParamsParent`. When determining "suspended by", React will walk up the promise chain, find this parent, and use its `displayName`, which we set to `"params"`. `searchParams` work analogously --------- Co-authored-by: Josh Story <story@hey.com>
Author
Parents
Loading