next.js
cc02d668 - Avoid loading standalone React by separating render validation (#100467)

Commit
38 days ago
Avoid loading standalone React by separating render validation (#100467) ## Summary App Router server traces currently include the installed React package through shared framework modules. This separates render validation from dynamic tracking so server bootstrap imports cannot reach the validation code's React lookup. Validation keeps its direct `require('react')` inside renderer bundles, where bundler aliases select the appropriate React instance. The fetch patch marker also moves to a standalone module so reading it does not load the fetch implementation. The adapter minimal-server trace drops the installed React files and six validation-only framework files. This is an independent alternative to using the renderer React registry in #100466. These solutions are for comparison; only one should land. ## Performance Compared `bfe0ccd57f` against its immediate parent, `72895219d4`, in a small production `next start` benchmark on October 20, 2026. Both revisions used release builds, Turbopack-built applications, Node 24.21.0, and the same dependencies on an Apple M5 Pro. Cache Components and Partial Prefetching remained enabled. | Measurement | Base → branch | Change | | --- | --- | --- | | JavaScript files loaded through the first API/static response | 473 → 463 | 10 fewer files | | JavaScript files loaded through the first dynamic response | 476 → 466 | 10 fewer files | | Loaded file-backed JavaScript source | About 214 KiB less | About 4.8% reduction | | Median process start → complete API response | 171.36 → 168.79 ms | 1.50% faster | | Median process start → complete static response | 168.60 → 167.33 ms | 0.75% faster | | Median process start → complete dynamic response | 412.08 → 410.69 ms | 0.34% faster | Startup measurements used 30 paired fresh-process trials per route, alternating revision order, with TCP-only readiness and exactly one HTTP request. The branch completed sooner in 29/30 API pairs; the dynamic startup result was inconclusive. Separate instrumented captures reproduced the same loaded-file sets twice; source sizes describe files loaded by the server, not browser downloads or allocated memory. Warm throughput was essentially unchanged across five paired trials per route: API −0.53%, static −0.11%, dynamic 0%. Each trial used 3 seconds of warmup, 10 seconds of measurement, and 50 keep-alive connections. The dynamic fixture includes a 200 ms wait, which limits its sensitivity to rendering overhead. All load trials completed without errors, timeouts, or non-2xx responses, and both revisions passed API, static response, dynamic freshness, and streaming behavior checks. These local measurements used warm filesystem caches and shared-machine load generation. They show reduced eager dependency loading and a modest API startup benefit; they do not establish serverless cold-start gains or a material warm-throughput improvement. ## Verification - `pnpm test-start-turbo test/production/next-server-nft/next-server-nft.test.ts` — 6 tests and 5 snapshots passed. - `pnpm test-start-webpack test/e2e/app-dir/app/standalone.test.ts` — 2 tests passed, including Edge runtime bundling. - Existing Cache Components error coverage for RSC (Dynamic Root) and SSR (`useSearchParams`) passed with both Turbopack and webpack: 2 tests and 2 snapshots per bundler. - `pnpm test-dev-turbo test/e2e/app-dir/cache-components-errors/{client,sync-dynamic}.test.ts -t 'useSearchParams in Client Components|Dynamic Root'` - `pnpm test-dev-webpack test/e2e/app-dir/cache-components-errors/{client,sync-dynamic}.test.ts -t 'useSearchParams in Client Components|Dynamic Root'` <!-- NEXT_JS_LLM -->
Author
Parents
Loading