4 Commits

Author SHA1 Message Date
Luke Sandberg a7b04690e6 gitignore .next-profiles (#95256)
### What?

When profiling is enabled (`--experimental-cpu-prof` /
`--internal-trace`, or the `NEXT_CPU_PROF` / `NEXT_TURBOPACK_TRACING`
env vars), Next.js writes a `.gitignore` containing `*` into
`.next-profiles/` as it creates the directory. This keeps the profiling
output out of git and out of the way of tools that scan the project
tree.

### Why?

`.next-profiles` is a sibling of `.next`, so it's intentionally *not*
covered by the `.gitignore` create-next-app ships. The motivation was
that profiles wouldn't bloat `.next` and wouldn't be silently ignored.
But a sibling dir full of large profile/trace files turns out to be a
liability:

- **Ecosystem tools scan it.** Tailwind v4 aggressively auto-scans files
and has opened a `trace-turbopack.bin` and crashed; Turborepo <2.8.13
hashes the file and OOMs, and >=2.8.13 fails to start `dev` watchers
because reading the large trace is too slow. (workflow watchers are
likely affected too.)
- **Turbopack NFT globbing** can read/hash the file via overly broad
`fs.read` patterns.
- **Accidental commits.** Pushing a multi-GB trace would be miserable
for a customer helping us debug.

These have each gotten point bandaids (#94587, #94570), but the real fix
preserves the original motivation: a nested `.gitignore` with `*` keeps
the files off git **and** makes gitignore-respecting tools (Tailwind,
Turborepo) skip the whole subtree, which resolves the scanning failures.
Reverting to `.next/profiles` was the alternative; the gitignore
approach keeps the existing path.

### How?

- `ensureProfilesDir()` (`packages/next/src/lib/profiles-dir.ts`)
creates `.next-profiles` and writes the `.gitignore` (only if absent, so
user edits survive). Single source of truth.
- `bin/next.ts` calls a `setupProfilesDir()` helper on build/dev/start,
gated on the env vars so both the CLI flags and direct env-var usage are
covered. Skipped when `NEXT_TURBOPACK_TRACING_PATH` redirects trace
output.
- Rust keeps `create_dir_all` as a backstop for the trace dir; the
`.gitignore` is written in JS only.
- Docs switched from `NEXT_TURBOPACK_TRACING=1` to `next dev
--internal-trace`, and the stale `trace-turbopack` filename corrected to
`trace-turbopack.bin`.

<!-- NEXT_JS_LLM_PR -->
2026-07-01 15:51:33 +00:00
Razin Shafayet d8426d0d04 docs: correct wording and casing in turbopack tracing guide (#94469)
Fixed two missing words and inconsistent capitalization in
`contributing/turbopack/tracing.md`:

- "And there different value modes" → "And there `are` different value
modes"
- "more information how to create one" → "more information `on` how to
create one"
- "Persistently `allocated` Memory" → "Persistently `Allocated` Memory"
2026-06-05 10:12:53 +02:00
Tim Neutkens c5596dd4e0 Turbopack: Write trace file to .next-profiles (#92189)
## What?

Builds on #92078. Also writes the Turbopack trace to the same
.next-profiles directory.
2026-04-08 16:50:17 +02:00
Benjamin Woodruff ae6406afdd docs(turbopack): Copy over turbopack-trace-server docs (#91111)
**Rendered:** https://github.com/vercel/next.js/blob/dd1cc6fba3cff5fbc38dac3ff4426b481bfcbcb5/contributing/turbopack/tracing.md

This is the content from https://turbopack-rust-docs.vercel.sh/tracing_turbopack.html with some minor updates:

- Use GitHub Flavored Markdown for the warning block
- Some grammar fixes/tweaks
- Add an extra note about `--release` being important
- Add a mention of `pnpm next internal trace`
- Add a link to @timneutkens's youtube video
- Change the filepath from the old confusingly named `.next/trace.log` to `.next/trace-turbopack`
- Add a link to https://trace.nextjs.org/
2026-03-09 16:04:07 -07:00