Include async module evaluation in client loading metrics (#99427)
## Summary Include async client-module evaluation in loading metrics. A module with top-level `await` can make `require()` return a Promise; measuring only until that return omits the subsequent evaluation wait. This follows #99322 and addresses [Hendrik’s review](https://github.com/vercel/next.js/pull/99322#discussion_r4132744744). Observe native Promise resolution and rejection while preserving the original return value and per-render attribution. Synchronous modules keep their existing behavior, including exports named `then` and thrown errors. ## Verification - End-to-end regression: a real Client Component waits five seconds during top-level `await`; an HTML request must report more than one second of accumulated loading time through the standard Performance API. The pre-fix code reported only 38 ms; the fixed code passes. - Replaced the PR-added mocked-loader tests. The existing eight logger tests remain unchanged and pass. - Full client-loading group: dev Webpack and production Turbopack, 6 passed each. Types, lint, formatting, and the full build pass. <!-- NEXT_JS_LLM -->
Showing
Please
register
or
sign in
to comment