next.js
852dd12f - Keep the local span recorder out of production server bundles (#102308)

Commit
19 hours ago
Keep the local span recorder out of production server bundles (#102308) ### Why? #98677 made `request-insights.ts` import `reparentLocalSpans` from `local-span-recorder.ts`. `patch-fetch.ts` imports `request-insights.ts`, so the development-only span recorder now ships in every production server bundle that patches `fetch`. Server JS grew +1.25% in `16.5.0-canary.41` on the hello-world benchmark, mostly from this recorder. ### How? Move `importRequestInsightSpans()` into `import-request-insight-spans.ts`. Only the development validation path in `app-render.tsx` imports it, so production bundles no longer pull in the recorder. `request-insights.ts` exports `shouldRecordRequestInsightSpan()` so both modules keep using the same filter. Behavior doesn't change. On the hello-world benchmark, server JS goes from 1,362.5 KB to 1,352.4 KB (−10.1 KB, −0.74%), which recovers about 60% of the canary.41 regression, and the recorder no longer appears in server chunks. <!-- NEXT_JS_LLM --> Co-authored-by: vercel-v[bot] <353008837+vercel-v[bot]@users.noreply.github.com>
Author
Parents
Loading