next.js
08954138 - Add next internal upload-trace (#92191)

Commit
1 day ago
Add next internal upload-trace (#92191) ### What? Adds `next internal upload-trace` CLI command for uploading CPU profiles and Turbopack traces to Vercel Blob storage. ### Why? When investigating performance issues, the Next.js team often needs CPU profiles and Turbopack traces from contributors and bug reporters. Currently there's no streamlined way to collect these files. This command provides a single step to upload all profiling output after a build. ### How? - **`.next-profiles` directory**: CPU profiles (`--experimental-cpu-prof`) and Turbopack traces (`--internal-trace`) now write to `.next-profiles/` instead of separate locations, consolidating all profiling output. - **`next internal upload-trace [directory]`**: New CLI command that uploads `.cpuprofile` files and `trace-turbopack` from `.next-profiles/` to Vercel Blob via a secure handshake with an external API endpoint. - Validates file headers before upload (JSON for `.cpuprofile`, binary for `trace-turbopack`) - Skips empty files - Shows progress bar in TTY environments - Groups all files under a single server-assigned session ID - Only logs the session ID to the user (no internal blob URLs exposed) - **`@vercel/blob` compiled**: Vendored into `packages/next/src/compiled/@vercel/blob/` via ncc. - **`--internal-trace` CLI flag**: Added to `next build` and `next dev` to enable Turbopack tracing to `.next-profiles/trace-turbopack`. - **Security**: The server controls the storage path (client only sends filename), session continuity uses HMAC-signed tokens (stateless across serverless instances), `allowOverwrite: false` prevents replacing existing uploads, and filenames are validated against an allowlist. - **Tests**: Added production test suite with a mock HTTP server. Usage: ```bash next build --experimental-cpu-prof --internal-trace next internal upload-trace ```
Author
Parents
Loading