Scope client component loading metrics to HTML renders (#99322)
## Summary To measure how client component loading affects HTML render performance, replace telemetry based on process-global counters and incoming request-body completion. Those boundaries mixed overlapping renders and measured a lifecycle unrelated to HTML production. Scope the counters and reporting context to each HTML-producing render. Start tracking before SSR, finish dynamic measurements at React readiness (Node `onAllReady` / Web `allReady`), and finish prerendering when the prerender operation returns. Preparation, action execution, and dedicated Flight rendering do not start tracking. DATA-only resumes finish tracking locally without waiting for output; an empty tracker emits no span. HTML rendered after a form action is still measured. Already-started loads may settle and report afterward without keeping the response open. Preserve the first-write performance snapshot, but remove metrics stream wrapping and binding. This advances the larger effort to remove req/res lifecycle assumptions from App Router rendering without adding telemetry to `after()`. Behavioral tests cover overlapping renders in both completion orders, HTML after a form POST, enhanced actions that only produce Flight, and HTML readiness while unused Flight content remains blocked. ## Verification - Confirmed both new boundary regressions failed before the runtime change. - Five behavioral metrics cases pass in development and production with both Turbopack and Webpack. - Full production Turbopack instrumentation suite: 109 passed, 13 existing skips. - Focused logger/response-piping units: 11 passed. Full repository build, package/root types, scoped Prettier, ESLint, and diff checks pass. - A broader unit run passed 3,065 tests but hit three macOS `/var` versus `/private/var` assertions in unchanged TypeScript CLI tests. Existing Node response-disconnect propagation to upstream SSR is unchanged; this PR does not claim to fix cancellation. <!-- NEXT_JS_LLM -->
Showing
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Please
register
or
sign in
to comment