- 07 Oct, 2026 23 commits
-
-
next-js-bot[bot] authored
-
Will Binns-Smith authored
## Summary Mark `next analyze export` and `next-bundle-optimizer` as added in v16.4. Add version history entries to the AI agents guide, package bundling guide, and CLI reference. ## Verification - Prettier and ESLint passed. - Runtime tests not run (docs only). <!-- NEXT_JS_LLM --> --------- Co-authored-by:Jan Kassens <kassens@vercel.com>
-
Aurora Scharff authored
### What When `experimental.agentFeedback` is enabled, create-next-app now writes the `nextjs-agent-feedback` block into `AGENTS.md` along with the `nextjs-agent-rules` block. ### Why Before this change, create-next-app enabled the flag in `next.config.ts` but only wrote the rules block. The feedback block was added later by `next dev`, and only when `@vercel/detect-agent` found a coding agent (`syncAgentFeedbackForDev` in `app-info-log.ts`). As a result: - An agent that read `AGENTS.md` before running `next dev` never saw the feedback instructions. - The block then appeared as an uncommitted `AGENTS.md` change on top of the "Initial commit from Create Next App". ### How - `generateAgentFiles(root, { agentFeedback })` adds the feedback block after the rules block. The text is copied from `packages/next/src/server/lib/generate-agent-files.ts`, with a comment saying to keep them in sync. `next dev` compares the block byte-for-byte. - `create-app.ts` passes `agentFeedback: !example && agentFeedback`, because examples don't get `experimental.agentFeedback` written to their config. - `--no-agents-md` still writes no `AGENTS.md`. ### Verification I ran the new helper next to `next dev`'s `writeAgentFiles` + `writeAgentFeedbackFiles`, with the flag on and off: - The output is byte-identical in both cases. - `hasCurrentAgentRules` / `hasCurrentAgentFeedback` return true on create-next-app's output. - Running `next dev`'s writers again on that output returns `unchanged`. Tests in `test/production/create-next-app/index.test.ts`: - `--agents-md --agent-feedback` writes the rules block, then the feedback block, and `next dev`'s `writeAgentFiles` / `writeAgentFeedbackFiles` both report `unchanged`. This catches drift between the two copies of the text. - `--agents-md --no-agent-feedback` writes only the rules block. - `--no-agents-md --agent-feedback` creates no `AGENTS.md`.🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by:Claude Opus 5.5 <noreply@anthropic.com>
-
Jan Kassens authored
These were breaking some GitHub builds for me for some reason. ## Test Plan GitHub CI + local cargo check validation
-
Aurora Scharff authored
## Summary Make each skill named by `next-bundle-optimizer` directly installable when it is unavailable, matching the inline handoff pattern used by the other Next.js skills. ## Verification - `pnpm prettier --with-node-modules --ignore-path .prettierignore --write skills/next-bundle-optimizer/SKILL.md` - Not run: runtime tests (skill text only) <!-- NEXT_JS_LLM -->
-
Sebastian "Sebbie" Silbermann authored
Increases test concurrency for the deploy test jobs to 8 (prev: 2 in the full suite, 1 in new build-and-test jobs). For deploy tests, the CPU-intensive work that should be as stable as possible (the Next.js build and server) does not happen on the runner. It happens remotely when the deployment is built at Vercel. The runner mostly handles I/O and setup: pushing the deployment, waiting for it to become ready, polling logs, and making requests against it. So the usual reason to cap concurrency (runner CPU contention) barely applies. Adjusted rate-limits: - 10x `api-projects-get` (prev failure: https://github.com/vercel/next.js/actions/runs/37617890690/job/112780953612#step:35:1159) Trade-offs to watch: - Peak concurrent Vercel deployments per run rises 4× (shards × 2 → shards × 8; 64 → 256 concurrent test files at today's shard counts). If we hit Vercel account deployment-concurrency limits, increase the limits - maybe we still need a bit beefier runners if the concurrent setup/tests starve runner CPU ## test plan - [x] [deploy tests with debug logging on this branch takes 30 minutes wall time without hitting Vercel rate limits](https://github.com/vercel/next.js/actions/runs/37627918534); usual flake on the 1st try (down from [97 minutes on canary](https://github.com/vercel/next.js/actions/runs/37588790388/attempts/1)) --------- Co-authored-by:
Claude Code <noreply@anthropic.com>
-
next-js-bot[bot] authored
-
Tobias Koppers authored
### What? Fixes the `rust check` (clippy) and `test cargo unit` jobs on canary, which fail with: ``` error[E0063]: missing field `active_worker_threads` in initializer of `TraceRow<'_>` --> turbopack/crates/turbopack-trace-size/src/lib.rs:936:13 ``` The fix adds the missing field to the `TraceRow::MemorySample` row in the `turbo-trace-size` unit test. ### Why? This was a semantic merge conflict between two PRs that each passed CI on their own: - #99233 added `active_worker_threads` to `TraceRow::MemorySample`. - #99765 added the `turbo-trace-size` crate, whose test builds a `MemorySample` row without that field. Only test code is affected. Every other `MemorySample` constructor already sets the field. ### How? The test row now sets `active_worker_threads: 3`. The size assertions are computed from the serialized rows, so they don't change. Verified locally on top of `db03f83f`: before the change, `cargo test -p turbopack-trace-size` fails with the error above. After it, the following pass: - `cargo test -p turbopack-trace-size` - `cargo clippy --all-targets -- -D warnings` for `turbopack-trace-size`, `turbopack-trace-utils` and `turbopack-trace-server` - tests of `turbopack-trace-utils` and `turbopack-trace-server` <!-- NEXT_JS_LLM --> <!-- fleet 4a52842b-f1a2-43cb-9779-3655caada6a0 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Niklas Mischkulnig authored
**View diff without whitespace** Call these just once (per module), not once per referenced import - `unused_references()` - `reference.get_referenced_asset()` - `imported_module.get_ident(export)`
-
Tobias Koppers authored
## Summary Adds a `no-memory` flag to `NEXT_TURBOPACK_TRACING`, next to `gz`/`gz-best` (e.g. `NEXT_TURBOPACK_TRACING=1,no-memory`). With the flag, `RawTraceLayer` writes no allocation counters for span enters/exits and no `MemorySample` rows. Without memory data, a trace of `bench/heavy-npm-deps` is about a third of the size. Use it when only timing data matters. - `RawTraceLayerOptions { memory: bool }` (default `true`), with `RawTraceLayer::with_options`. `RawTraceLayer::new` keeps the old behavior. - The flag is documented in `contributing/turbopack/tracing.md`. Part of a stack that reduces the trace file size (#99765 adds the `turbo-trace-size` CLI used for the measurements): 1. #99777: **This PR**: `no-memory` flag 2. #99778: Merge allocation counters into Enter/Exit rows 3. #99779: Delta-encode allocation counters, skip unchanged ones 4. #99780: Omit Exit+Enter pairs with (almost) no gap 5. #99781: Bump the trace header to `TRACEv1` ## Measurements `next build` of `bench/heavy-npm-deps`, release native binding built from source (`image-extended,tracing/release_max_level_trace`): | flags | trace size | | --- | --- | | `1` | 68.2 MiB | | `1,no-memory` | 23.3 MiB | ## Verification - New unit tests in `raw_trace.rs` decode a captured trace (with and without memory tracking) - Captured both traces above with a locally built binding <!-- NEXT_JS_LLM --> <!-- fleet 4a52842b-f1a2-43cb-9779-3655caada6a0 --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
### What? Adds `turbopack/crates/turbopack-trace-size`, a CLI (`turbo-trace-size`) that shows where the bytes in a Turbopack trace file (`.next-profiles/trace-turbopack.bin`) go. It decodes the postcard `TraceRow` stream (raw, gzip or zstd) and reports: - size per row type (`Start`, `Enter`, `Exit`, `AllocationCounters`, ...) - the components of `Start`/`Event`/`Record` rows (name, target, values, fixed fields) - bytes per span name, including its Enter/Exit/End/Record rows and Events - bytes per attribute key - the bytes spent re-writing the same span names, targets, keys and string values ```sh cargo run --bin turbo-trace-size --release -- .next-profiles/trace-turbopack.bin --top 30 ``` ### Why? `NEXT_TURBOPACK_TRACING` traces get large quickly. This tool shows which events cause that, so we can decide what to slim down. ### Findings: `bench/heavy-npm-deps`, `NEXT_TURBOPACK_TRACING=1 next build` 68.42 MiB raw, 4.66 M rows (gzip -1: 21.3 MiB, zstd -3: 21.2 MiB): | row type | count | bytes | avg | % | | ------------------ | --------: | --------: | -----: | ----: | | AllocationCounters | 2,280,168 | 45.00 MiB | 20.7 B | 65.8% | | Exit | 1,140,084 | 8.40 MiB | 7.7 B | 12.3% | | Enter | 1,140,084 | 8.40 MiB | 7.7 B | 12.3% | | Start | 39,481 | 5.57 MiB | 148 B | 8.1% | | Record | 21,913 | 804 KiB | 38 B | 1.1% | | End | 39,480 | 265 KiB | 7 B | 0.4% | | MemorySample | 244 | 2.5 KiB | 10 B | 0.0% | | Event | 8 | 368 B | 46 B | 0.0% | - **AllocationCounters take 66% of the file.** `RawTraceLayer` writes one before every `Enter` and every `Exit`, so there are exactly 2× as many as Enter rows. Each one holds an absolute timestamp, the thread id and 4 cumulative counters. - **Enter/Exit take another 25%.** Each span is entered about 29 times on average, because async spans are re-entered on every poll. `module` (module_graph) and `process module` are the biggest, at about 6.3–6.5 MiB each. - **Start rows are 8%**, mostly attribute values: `name` (2.6 MiB), `lookup_path` (1 MiB), `reference_type` (0.6 MiB). - **Repeated span names, targets and keys** come from only 147 distinct strings. At most about 3% could be saved by writing each one once, before the cost of referencing them. String values could save at most another 4%. So skipping or delta-encoding the allocation counters, and delta-encoding Enter/Exit timestamps, would cut the size far more than interning strings would. That is left for a follow-up. Note: the trace was captured with the published `@next/swc-linux-x64-gnu@16.4.0-canary.31` native binary that `pnpm install` put in place, running with JS built from this checkout (16.5.0-canary.1). It was not a source-built native binding. ### How? - The crate reuses `TraceRow`/`TraceValue` from `turbopack-trace-utils` and reads the stream incrementally. Every row byte is counted, so rows + header add up exactly to the decompressed size. - Rows are written from per-thread buffers, so Enter/Exit/End rows can show up before the `Start` of their span. Like the trace server, the tool queues those rows until the `Start` arrives and keeps id mappings after `End`. - `contributing/turbopack/tracing.md` now documents the tool. ### Verification - `cargo test -p turbopack-trace-size`: unit tests check byte accounting against postcard, gzip (multi-member) and zstd input, rows split across reads, headerless files, an incomplete last row, invalid rows, cross-thread ordering and reused ids. - `cargo clippy -p turbopack-trace-size --all-targets -- -D warnings` - Ran it on the trace above: raw, gzip and zstd copies give identical breakdowns, and rows + header = 71,739,555 B, the exact file size. <!-- NEXT_JS_LLM --> <!-- fleet 4a52842b-f1a2-43cb-9779-3655caada6a0 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Jiwon Choi authored
## Summary Use ESLint `^10` in create-next-app projects so fresh apps no longer install deprecated ESLint 9. Update the existing TypeScript and JavaScript configuration tests to assert the exact dependency range. Some ESLint plugins still declare peer support only through ESLint 9, so installs can report peer dependency warnings. ## Verification Generated TypeScript and JavaScript apps installed ESLint 10.12.0 and passed their lint scripts using locally built `eslint-config-next` and `@next/eslint-plugin-next` packages. <!-- NEXT_JS_LLM -->
-
Aurora Scharff authored
## Summary - prevent `cache-components-instant-false` from adding route config to colocated test, spec, and story files - keep compound page extensions eligible while filtering common non-route suffixes - cover POSIX and Windows paths in the regression tests ## Verification - `pnpm --filter @next/codemod build` - `pnpm --filter @next/codemod test --runInBand cache-components-instant-false.test.js` <!-- NEXT_JS_LLM -->
-
Tobias Koppers authored
### What? Makes loading compressed (`.zst` / `.gz`) traces in `turbo-trace-server` much faster. On a large trace, compressed loads now beat raw loads from before this change. Raw loads get faster too. | 12M-span synthetic trace (warm cache, median) | before | after | |---|---|---| | raw | ~17s | ~13.5s | | `.zst` | ~26s | ~14s | | `.gz` | ~26s | ~12s | Smaller synthetic traces (2–3M spans) improve as well: - raw goes from 3.5–4.9s to 2.2–3.3s; - compressed goes from 2.2–3.7s to 2.1–2.9s. ### Why? Opening compressed traces was very slow. There were two causes. 1. **Per-batch work was quadratic.** - After every batch of rows, `Store::invalidate_outdated_spans` cleared the cached corrected self time of **every** self-time event of each touched span, plus its ancestors and the root. - For a span with millions of events, that is a full scan per batch. 2. **Compressed input arrived in tiny batches.** - zstd/gzip decoders return about one input buffer of output per `read`, roughly 450 KB. - Raw files arrived in 64 MB reads. - So compressed traces ran that full scan about 100× more often. On the trace above, invalidation alone took ~12.7s for `.zst` versus ~1.5s for raw. ### How? **Constant-time cache invalidation.** - Each span now has a generation counter for the cached corrected self times of its self-time events. - Invalidating a span just bumps the counter. A cached per-event value only counts if it was computed for the span's current generation. - The value and its generation are stored as two atomics in the event, replacing the `OnceLock`, so `SpanEvent` stays 32 bytes. `Span` grows by 8 bytes. - The counter only changes under the store's write lock. Concurrent readers can at worst both compute and store the same value. - Invalidation semantics are unchanged: the touched span, its ancestors and the root. The new store tests pass against both the old and the new implementation. **Decompression on a background thread** (`reader/threaded.rs`). - zstd and gzip streams are decoded on a dedicated thread. It fills batches and sends them to the reader over a bounded channel, so decompression overlaps parsing. - Buffers are recycled. - Errors are sent after the data that came before them, so an error the decoder reports only once is never lost. gzip checksum errors are an example. - After EOF or an error, the thread pauses until the reader asks for more data. This keeps the existing "wait for the file to grow, then retry" behavior. - The reader sees a panic on the decoder thread as an error, not as EOF. - Dropping the decoder closes the channels and joins the thread, both when the thread is paused and when it is blocked on a full channel. - For progress reporting, the reported position is the compressed-file offset the decoder thread has consumed. It never decreases and can run ahead of parsing by the queued batches. - STOP_AT polling now reads the file size from a cloned file handle instead of seeking to the end. **1 MB batches for all formats.** Once per-batch invalidation is cheap, small batches are faster: 1 MB batches parse about 1.3–1.6× faster than 64 MB ones, for raw and compressed input alike. ### Testing `cargo test -p turbopack-trace-server` passes, including new tests for: - **Store:** - cached values are reused until a span is invalidated, then recomputed; - invalidation reaches ancestors and the root; - concurrent corrected-self-time reads match serial results. - **Threaded decoder:** - gzip and zstd streams round-trip exactly; - errors arrive after the preceding data (one-shot errors and a real corrupt gzip CRC); - truncated streams deliver their readable prefix; - `Interrupted` reads are retried, and reading resumes after EOF; - a worker panic surfaces as an error; - dropping the decoder shuts the thread down while it is paused or backpressured; - the reported position is monotonic. - **Reader:** - raw, zstd and gzip versions of a trace load identically; - raw live tailing picks up appended data; - truncated compressed files load their prefix. Checked manually against the previous binary on synthetic traces: - span counts are identical for every format; - truncated and corrupt-checksum files load the same number of spans; - STOP_AT still works. Known limitations, unchanged by this PR: - live tailing of compressed traces doesn't pick up appended data; - gzip checksum errors are still treated like EOF without a warning. <!-- NEXT_JS_LLM --> <!-- fleet 7727f609-8d7f-49aa-8f67-2aefbafe3f2e --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Niklas Mischkulnig authored
- ~~Blocked by https://github.com/swc-project/plugins/pull/662 because box_patterns was removed~~ - ~~Blocked on https://github.com/rust-lang/miri/commit/87c4b123697e210ba99c5fc004049bb59acb2df0 so that Miri just works again~~ - Upgrade napi-build for https://github.com/napi-rs/napi-rs/pull/3492 to fix `duplicate symbol: _initialize` in WASM Still running into ``` @next/swc:test-cargo-unit-miri: error: unsupported operation: fdatasync is only supported on file-backed file descriptors @next/swc:test-cargo-unit-miri: --> /home/runner/.rustup/toolchains/nightly-2026-10-06-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/fs/unix.rs:1279:13 @next/swc:test-cargo-unit-miri: | @next/swc:test-cargo-unit-miri: 1279 | libc::fdatasync(fd) @next/swc:test-cargo-unit-miri: | ^^^^^^^^^^^^^^^^^^^ unsupported operation occurred here @next/swc:test-cargo-unit-miri: | @next/swc:test-cargo-unit-miri: = help: this is likely not a bug in the program; it indicates that the program performed an operation that Miri does not support @next/swc:test-cargo-unit-miri: = note: this is on thread `tests::whole_ke` @next/swc:test-cargo-unit-miri: = note: stack backtrace: @next/swc:test-cargo-unit-miri: 0: std::sys::fs::unix::File::datasync::os_datasync @next/swc:test-cargo-unit-miri: at /home/runner/.rustup/toolchains/nightly-2026-10-06-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/fs/unix.rs:1279:13: 1279:32 @next/swc:test-cargo-unit-miri: 1: std::sys::fs::unix::File::datasync::{closure#0} @next/swc:test-cargo-unit-miri: at /home/runner/.rustup/toolchains/nightly-2026-10-06-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/fs/unix.rs:1258:27: 1258:56 @next/swc:test-cargo-unit-miri: 2: std::sys::pal::unix::cvt_r::<i32, {closure@std::sys::fs::unix::File::datasync::{closure#0}}> @next/swc:test-cargo-unit-miri: at /home/runner/.rustup/toolchains/nightly-2026-10-06-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/pal/unix/mod.rs:250:19: 250:22 @next/swc:test-cargo-unit-miri: 3: std::sys::fs::unix::File::datasync @next/swc:test-cargo-unit-miri: at /home/runner/.rustup/toolchains/nightly-2026-10-06-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/fs/unix.rs:1258:9: 1258:59 @next/swc:test-cargo-unit-miri: 4: std::fs::File::sync_data @next/swc:test-cargo-unit-miri: at /home/runner/.rustup/toolchains/nightly-2026-10-06-aarch64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/fs.rs:823:9: 823:30 @next/swc:test-cargo-unit-miri: 5: fs_err::File::sync_data @next/swc:test-cargo-unit-miri: at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/fs-err-3.3.1/src/file.rs:109:9: 110:25 @next/swc:test-cargo-unit-miri: 6: db::commit_current::{closure#0} @next/swc:test-cargo-unit-miri: at turbopack/crates/turbo-persistence/src/db.rs:252:25: 252:40 ```
-
Niklas Mischkulnig authored
This removes the last cases of box_patterns from our build
-
next-js-bot[bot] authored
-
Sebastian "Sebbie" Silbermann authored
lerna's last job was bumping the version, and it needed a dependency graph of exact pins to do it. Internal dependencies now use the `workspace:*` protocol instead, which pnpm substitutes for the concrete version when packing, so published manifests are unchanged. `workspace:*` resolves to the same bare exact version that was pinned before. That leaves the bump itself, which `scripts/version-bump.js` now does: write one version field per package, commit, tag. It stays small because every package is versioned in lockstep and releases always bumped all of them (`--force-publish`), so there is no changed-detection to reimplement. `packages/next/package.json` replaces `lerna.json` as the version source of truth. The release branch gate moves to `scripts/release-branches.json`. Three things fall out: - `normalize-version-bump.js` no longer has to normalize internal dependency specs, since `workspace:*` carries no version. Those specs also stop contributing to turbo input hashes. - `set-preview-version.js` no longer needs to check out a branch first. That only existed because `lerna version` refused to run on a detached HEAD. - no more lockfile regeneration after a release which means we can reuse n_m caches `create-preview-tarballs.js` keeps `npm pack`: it rewrites internal dependencies to tarball URLs rather than versions, because that is what preview installs need, so pnpm's substitution would be the wrong transform. It now throws if any `workspace:` specifier survives that rewrite. ## test plan ``` $ git switch -c scratch/release-dry-run sebbie/remove-lerna $ node scripts/start-release.js --release-type canary --dry-run Dry run: keeping commits locally, skipping git push and GitHub release creation Running release-canary... Bumping 16.4.0-canary.39 -> 16.4.0-canary.40 Updated 20 packages [...] Creating GitHub release v16.4.0-canary.40 (changelog range v16.4.0-canary.39..v16.4.0-canary.40, 30 commits) [dry-run] GitHub API POST /repos/vercel/next.js/releases {"tag_name":"v16.4.0-canary.40","name":"v16.4.0-canary.40","body":"### Misc Changes\n\n- Remove lerna\n- [PPF] Implement `unstable_ensureStatic = \"shell\" | \"prefetch\"` (#98191)\n- [PPF] Valid… (1939 chars)","prerelease":true,"draft":true} Created draft prerelease v16.4.0-canary.40 Release process is finished $ git show HEAD --oneline c198fa45fae (HEAD -> scratch/release-dry-run, tag: v16.4.0-canary.40) v16.4.0-canary.40 $ node scripts/publish-release.js --dry-run $ git diff diff --git a/packages/next/package.json b/packages/next/package.json [...] "optionalDependencies": { - "sharp": "^0.35.4" + "sharp": "^0.35.4", + "@next/swc-darwin-arm64": "16.4.0-canary.40", + "@next/swc-darwin-x64": "16.4.0-canary.40", + "@next/swc-linux-arm64-gnu": "16.4.0-canary.40", + "@next/swc-linux-arm64-musl": "16.4.0-canary.40", + "@next/swc-linux-x64-gnu": "16.4.0-canary.40", + "@next/swc-linux-x64-musl": "16.4.0-canary.40", + "@next/swc-win32-arm64-msvc": "16.4.0-canary.40", + "@next/swc-win32-x64-msvc": "16.4.0-canary.40" }, [...] diff --git a/packages/third-parties/package.json b/packages/third-parties/package .json index 7a7fab8790..8cbf23b9cd 100644 --- a/packages/third-parties/package.json +++ b/packages/third-parties/package.json @@ -32,7 +32,7 @@ "typescript": "6.0.2" }, "peerDependencies": { - "next": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0", + "next": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || 16.4.0-canary.40", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0" } ``` -
Alex Kulikovskikh authored
-
Benjamin Woodruff authored
Minor cleanup opportunities I noticed after reviewing https://fleet-review.vercel.tools/vercel/next.js/pull/99711/changes/ba6208431008d331bb3c738cd32643c61c04f411..18e7c6dee5d4f85aa1c9a9a68a50830fc73b52f8
-
Tobias Koppers authored
## Summary Stacked above #99254. Allow `blocking = true` on elapsed-duration events and entered tracing spans, using the same ignore-self-time accounting as existing `blocking` spans. Waiting durations otherwise inflate concurrency and CPU totals even after the tasks yield—for example, a pending fetch emits overlapping request and attempt durations. Blocking spans now keep their elapsed ranges and metadata, but contribute no own CPU time, corrected time or concurrency, and do not affect other work's correction factor. Counted descendants remain included. Classify network and Node.js pool-acquisition waits as blocking, while keeping Node.js startup, initialization and evaluation counted as external work. Missing/false attributes preserve legacy accounting. No trace format or viewer payload changes. Existing name-exempt `thread`/`blocking` spans also retain their full elapsed end now, rather than dropping it along with self-time. Attributes are classified at creation, not retroactively via record updates. External-work durations remain elapsed approximations, not OS-measured CPU time. ## Verification - 85 trace-server/trace-utils tests passed, including new reader regressions for flags, retained ranges, counted children, correction factors and live cache invalidation; affected Rust producers and native bindings compile. - Rebuilt trace server queried over WebSocket: the 40-wait fixture changes from concurrency 80 to 0 during the wait when its duration events carry `blocking = true`. Root CPU totals drop from 8002ms to the 2ms entered work; waiting leaf retains its 100ms elapsed range with zero CPU/corrected duration. - No new benchmark screenshot: actual raw-reader tests and the rebuilt-server fixture verify the changed accounting. <!-- NEXT_JS_LLM --> <!-- fleet 0c297c2c-8e55-4012-be8a-752ff8175d1b --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
## Summary Show how much traced work was happening concurrently throughout a selected span. The trace server divides its range into up to 200 equal-duration segments and returns the time-weighted average number of active global self-time intervals per segment as `concurrencySamples` in the WebSocket query result. It traverses the self-time tree once and rounds averages to hundredths. **Depends on [#99233](https://github.com/vercel/next.js/pull/99233)** and targets its branch so this PR only adds derived concurrency samples. The matching [trace-viewer PR](https://github.com/vercel/turbo-trace-viewer/pull/36) graphs the new values. ## Verification - `cargo test --locked -p turbopack-trace-server` (28 library and 27 binary tests pass) - `cargo check --locked -p next-napi-bindings` - Local native build, `pnpm build-all`, and traced `bench/heavy-npm-deps` Turbopack build passed. The generated 272 MB trace contained 851,901 spans and showed nonzero concurrency for the selected top-level span in the updated viewer. <!-- NEXT_JS_LLM --> <!-- fleet 0c297c2c-8e55-4012-be8a-752ff8175d1b --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Tobias Koppers authored
## What? Record the number of non-idle Tokio scheduler worker threads alongside Turbopack's existing process-memory samples. The span-query API and MCP output expose it as the fourth value in each memory sample. The WebSocket query result adds a parallel worker series for visualization in [vercel/turbo-trace-viewer#33](https://github.com/vercel/turbo-trace-viewer/pull/33), retaining the original memory-only series. ## Why? Memory samples alone do not show whether Tokio's workers were busy or parked at a given point in a trace. The aligned worker count makes it easier to correlate memory changes and traced work with scheduler activity. ## How? Each traced runtime builder initializes one global atomic counter with its worker capacity, then Tokio's worker-only park/unpark callbacks adjust it. This avoids counting blocking-pool threads and assumes one traced Tokio runtime per process; shutdown bookkeeping is unnecessary for this metric. The counter is read at the existing memory-sampling cadence rather than emitting trace rows on each worker transition. Trace ingestion, span-query downsampling, and the WebSocket worker series preserve the count from the same sample as the selected memory value. ## Verification - `cargo test --locked -p turbopack-trace-utils -p turbopack-trace-server` - `cargo check --locked -p turbopack-cli -p turbopack-nft -p next-build-test -p next-napi-bindings` - `cargo fmt --all -- --check`; `git diff --check` - Not run: Next.js TypeScript/prettier/full build (checkout has no `node_modules`). <!-- NEXT_JS_LLM --> <!-- fleet 0c297c2c-8e55-4012-be8a-752ff8175d1b --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
- 06 Oct, 2026 17 commits
-
-
Abhay Mishra authored
Fixes #97378 ### What? Turbopack turns a failed `next/font/google` font file download into an unresolvable request. Build then dies with: ``` Module not found: Can't resolve '@vercel/turbopack-next/internal/font/google/font' ``` Real cause (`Received response with status 404 when requesting <url>`) shows only as a warning earlier in the log. ### Why? Hit this on Vercel with 16.3.6 and EB Garamond. Build failed with 56 of these errors, redeploy of same commit passed. Nothing in the error pointed at the font download. ### How? Font file fetch now follows the stylesheet fetch: error in `next build`, warning in `next dev`. A failed file is served empty, so dev falls back to the next font in the stack. Retries unchanged; `max_retries: 1` already covers connect errors, timeouts and 5xx. Differs from #97520: dev keeps rendering instead of failing, message comes from the existing fetch issue, and global retry count and webpack mock stay as they are. ### Tests `test/e2e/next-font/google-font-file-fetch-error.test.ts`, Turbopack only, since webpack in mock mode does not download font files. Mocked stylesheet points at a missing gstatic file. Without the fix both dev and start fail with `Module not found`. With it both pass. `google-fetch-error` and `index` next-font suites still pass in Turbopack dev and start. `cargo clippy -D warnings`, rustfmt, prettier and eslint clean.
-
Will Binns-Smith authored
-
next-js-bot[bot] authored
-
Luke Sandberg authored
## Summary This experiment builds on the copy-on-write snapshot design from #99649, which is now on canary. It holds the operation exclusion while `take_snapshot` runs, so the scan can move modified bits into new `meta_snapshot_pending` / `data_snapshot_pending` bits safely. Holding the exclusion means a task touched for the first time during the snapshot doesn't need a `None` placeholder in `snapshots`. The map now stores only copy-on-write `SnapshotItem`s, and `end_snapshot` just leaves snapshot mode and clears the map. It no longer has to promote during-snapshot flags or take paired shard locks. Why: compare this simpler bookkeeping with #99649's approach, which keeps the scan outside the exclusion. The trade-off is that operations stay blocked during the O(N) capture scan. Encoding still happens later in the snapshot iterators, after the exclusion is released. This design was rejected earlier on #99649 ("delaying the snapshot to set these bits is not acceptable"), so this PR is meant for comparison, not as the assumed final direction. How: - The scan moves the modified bits into pending bits and records each captured task. - The first mutation of a captured task encodes all of its pending categories before the mutation, so cases where different categories change in different orders are covered. - Pending bits stay set until the iterator yields the task. Undo and eviction still see those bits until then. - Shutdown drain mode still uses the modified bits directly. - If persisting stops early (an error or a panic), each dropped shard clears the pending bits of its captured tasks that weren't yielded, before `end_snapshot` clears `snapshot_mode`. Pending bits never outlive a snapshot, so `track_modification` decides copy-on-write from the pending bits and the map alone, without reading `snapshot_mode`. The iterator removes a task from its list only after it has finished with that task, so a panic while encoding is cleaned up too. - The snapshot callbacks take a `TaskDataCategory` (`Meta` / `Data` / `All`) instead of a two-bool mask, because a persisted task always has at least one category. - The lower-layer changes are kept: the local copy-on-write buffer, stats on encoded items, and `LastPersistenceStatus`. ## Verification - `cargo test -p turbo-tasks-backend` - `cargo test -p turbo-tasks-macros-tests` - `cargo test -p turbo-tasks-backend --lib --features verify_serialization,print_cache_item_size` - `cargo clippy -p turbo-tasks-backend --all-targets -- -D warnings`, with default features and with `verify_serialization,print_cache_item_size` - Mutation check: skipping copy-on-write for tasks with pending bits made 6 tests fail. One of them shows the persisted meta bytes no longer matching the captured meta. - Failed-persist cleanup: `dropping_shards_early_leaves_no_copy_on_write_items` and `panic_while_encoding_clears_pending_flags` both failed before the shard-drop cleanup existed. Emptying the `Drop` cleanup makes both fail again. Removing a task from the list before encoding it makes only the panic test fail. The panic test is skipped on wasm, which can't unwind; the early-drop test still runs there. - wasm: `cargo test -p turbo-tasks-backend --lib --target wasm32-wasip1-threads` under `scripts/wasi-test-host` passes (108 passed, 14 ignored). - Not run: benchmarks of how long the exclusion lasts or how long a full snapshot takes. Holding the scan under the exclusion is a deliberate trade-off here. - Not run: `pnpm build-all` (this worktree has no `node_modules`). <!-- NEXT_JS_LLM --> <!-- fleet 98a896e8-00fa-4f81-97f0-48bd49e2a9a2 --> --------- Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
Josh Story authored
## Summary Loading custom routes currently writes original redirects and rewrites onto resolved configuration. Return the redirect metadata with the loaded routes for client-router filtering, and remove the unused rewrite snapshots and obsolete webpack arguments. This removes post-load config writes as part of making completed configuration immutable for adapters and other runtime consumers. ## Verification - Existing configured rewrites and redirects suite: 14 tests passed in development with both bundlers and in production with webpack. - Existing middleware redirect test exercises client navigation through a configured redirect with client-router filtering enabled in development with Turbopack and production with webpack. - Existing custom-route loader and next-types-plugin unit tests. <!-- NEXT_JS_LLM -->
-
Luke Sandberg authored
### What? During a snapshot, a task's first modification now copies the task's pre-mutation state whenever any of its categories is part of the snapshot, whichever category the modification touches. A `None` marker is inserted only for tasks with no modified category. ### Why? `track_modification` used to decide based on the touched category only. That let a snapshot persist inconsistent state. Take a task with dirty meta and clean data: 1. The snapshot begins. 2. Data is modified. Data wasn't part of the snapshot, so only a `None` marker is inserted. 3. Meta is modified. A marker is already present, so nothing is copied. 4. Persistence encodes the live meta, already mutated by step 3. ### How? The design is otherwise unchanged: `*_modified_during_snapshot` bits, `None` markers and the promotion in `end_snapshot` all stay, and nothing new happens inside the operation exclusion. Only the first-modification check in `track_modification_internal` changes, from "is the touched category modified" to "is any category modified". The copy still encodes with the live modified bits, so categories that weren't part of the snapshot aren't persisted. A regression test covers the sequence above. It checks that the persisted item carries the pre-snapshot meta and no data, and that both modifications are left for the next snapshot. <!-- NEXT_JS_LLM --> <!-- fleet 98a896e8-00fa-4f81-97f0-48bd49e2a9a2 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
-
Tobias Koppers authored
### What? A failed persist (the snapshot cycle returning an error or panicking) disables persisting for the rest of the session. Later persistence cycles, including the one at shutdown, are skipped: `snapshot_and_persist` returns `Ok(None)` without starting a snapshot or GC. ### Why? A failed persist leaves the task graph and the database out of sync. For example, `save_snapshot` may already have consumed `persisted_task_cache_log` entries. Persisting again after that could write inconsistent state. Split out of #99649 as requested in review. ### How? `snapshot_in_progress` (the mutex that serializes persistence cycles) now holds a `LastPersistenceStatus { Ok, Failed }`. The backend starts at `Ok`. The status is set to `Failed` before a cycle starts and reset to `Ok` only when the cycle succeeds, so a panic also leaves it `Failed` (`parking_lot` mutexes don't poison). `Failed` is sticky for the rest of the session. Treating a disabled persist as a skipped cycle means `stop` needs no separate check. The test helper skips eviction on `None`, as it does on an error. What the existing design does with tasks the failed snapshot didn't yield is unchanged. A unit test checks that a failed persist through the noop backing storage sets the status to `Failed`, and that the next persist returns `None` and leaves the task's modification for later. The panic path has no test, since that would need a backend test hook; it was checked by reading the control flow. <!-- NEXT_JS_LLM --> <!-- fleet 98a896e8-00fa-4f81-97f0-48bd49e2a9a2 --> --------- Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
-
Luke Sandberg authored
### What? When a task that is already part of an in-progress persistence snapshot is modified again, `track_modification_internal` now bincode-encodes the task's pre-mutation state into the `SnapshotItem` that persistence will write, and stores that in the `snapshots` map. Before, it stored a `clone_snapshot()` copy of the `TaskStorage`. ### Why? The copy-on-write path exists so persistence sees a consistent snapshot even if a task is mutated while the snapshot is being written. Cloning `TaskStorage` doesn't guarantee that: cell contents are held behind `SharedReference` (`Arc`), so the clone shares them with the live task. If a cell value has interior mutability, a later mutation shows up in the "frozen" copy and the persisted state is no longer consistent. Encoding the state right away captures plain bytes that later mutations can't reach. The snapshot iterator hands the stored item straight to persistence, so nothing is encoded twice. The only cost is holding the encoded buffers in memory until the racing persistence picks them up, and this race is rare. <!-- NEXT_JS_LLM --> <!-- fleet 98a896e8-00fa-4f81-97f0-48bd49e2a9a2 --> --------- Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com>
-
next-js-bot[bot] authored
-
next-js-bot[bot] authored
-
Jan Kassens authored
The world of AI is moving fast. Instead of hardcoding the available models, discover them from the CLIs. This is a bit hacky, but probably more reliable than hardcoding a list that will become outdated fast. The available models might be different for different accounts. This involved a bit of code moving as I wanted to have the model discovery run in parallel to displaying the user the harness selection to reduce delay in selecting the model. ## Test Plan: In addition to new tests, also tested interactively with: ``` DEBUG=next:upgrade node -e \ "require('./packages/next/dist/lib/upgrade/harness').handoffUpgrade('This is a harness test. Do not modify files.', process.cwd(), null).catch(console.error)" ``` -
next-js-bot[bot] authored
-
Will Binns-Smith authored
## Summary Document `next analyze export` with a snapshot capture/export example and a link to its CLI options. ## Verification - Prettier and ESLint passed. - Runtime tests not run (docs only). <!-- NEXT_JS_LLM -->
-
Andrew Clark authored
Stabilizing `forbidden()` and `unauthorized()` means the built-in 403 and 401 fallbacks are rendered into every page's payload, even for apps that don't define `forbidden.tsx` or `unauthorized.tsx`. On a fresh create-next-app that's about 2.3KB of uncompressed HTML per page (~125 bytes gzipped). I knew about the regression but I forgot that it applied to every app and every page, rather than just those that use `forbidden.tsx` or `unauthorized.tsx`. To avoid blocking the 16.4 release, we'll keep this feature in experimental for now until we fix the implementation to render the fallbacks lazily.
🤖 Generated with [Claude Code](https://claude.com/claude-code) -
Josh Story authored
## Summary Static export with a custom `distDir` currently overwrites that option with `.next` during the build. Keep the configured export destination intact and derive the intermediate build directory separately, so adapters receive the original option while their build-directory argument still points to the artifacts. This removes a post-load config mutation as part of making completed configuration immutable for adapters and other runtime consumers. Preserve support for both relative and absolute Turbopack project output paths. ## Verification - Existing adapter tests pass in both production bundlers; custom export-directory coverage passes with Turbopack. - Existing server trace suite passes with Turbopack: six tests and five snapshots. - Existing Rust API suite passes its 25 main cases and 15 snapshots in each bundler. Its RSS stabilization stress case fails locally on both this branch and unmodified canary. <!-- NEXT_JS_LLM --> --------- Co-authored-by:Jamiboy Mohammad <jamiboym@gmail.com>
-
Will Binns-Smith authored
## Summary Rename `next-browser-initial-load-optimizer` to `next-bundle-optimizer` and update the skill directory, metadata, links, and install commands. Document how to use the skill with Turbopack's bundle analyzer, with prompts for audits, fixes, and route-specific optimization. ## Verification - Prettier passed for the skill and both guides. - Runtime tests not run (docs and skill rename only). <!-- NEXT_JS_LLM -->
-
Tobias Koppers authored
## What? Task completion now cleans up the task's per-execution state (removing cells that no longer exist, `cleanup_after_execution`) under the same task lock that finishes the execution, before the completion is published (in-progress state removed, `done_event` notified). Previously the cleanup ran afterwards, under a second lock acquisition. A waiter could invalidate the task in that gap and its next execution could start. The old cleanup would then remove that execution's state, e.g. the `outdated_*_dependencies` it was just given, and could also remove cells it had created. ## Why? `collectibles_outdated_dependency` fails locally on canary (5/5 runs here) and passes in CI only by timing. Tracing showed the old cleanup observing the next collector execution already running with populated `outdated_collectibles_dependencies`, then clearing them. Later collectible emissions then made the waiting collector stale, so it executed an extra time. The optimization from #99386 assumes that bookkeeping is intact. There is a second, independent reason the test can see an extra execution: `State::set` invalidates its readers one at a time. The collector can then read the source before the source was invalidated, see the old collectibles, and legitimately re-execute when the new ones arrive. ## How? - `task_execution_completed_cleanup` now takes the held `TaskGuard`. `task_execution_completed_finish` calls it after setting output and immutability, before dropping the guard and notifying `done_event`. The canceled path still cleans up, and stale reschedules (including `verify_determinism` reruns) still skip cleanup, as before. Removed cell data is still dropped outside the critical section. - Tests: - The existing test is unchanged. Its docs now say it is timing-dependent and also covers this cleanup race. - A new gated variant stages the overlap explicitly: the collector waits until the new emitter execution has started, polls its strongly consistent source read to `Pending`, and only then lets the emitter emit. This deterministically covers the dirty-not-stale optimization, independent of `State` invalidation order. ## Verification - With the fix: both tests pass 30/30 locally, and `cargo test -p turbo-tasks-backend` passes. - Mutant (always stale on collectible change): the gated test fails 10/10. - Known limitation: there is no deterministic regression for the cleanup race itself without a backend test hook. With canary's ordering restored, the ungated test failed intermittently, between 0/20 and 8/20 depending on test layout and invocation. The fix was confirmed by tracing and by an experiment that widened the old gap. - Clippy (default and `verify_serialization,print_cache_item_size`), a `verify_determinism` check, and `cargo test -p turbo-tasks-macros-tests` pass. <!-- NEXT_JS_LLM --> <!-- fleet 98a896e8-00fa-4f81-97f0-48bd49e2a9a2 --> Co-authored-by:
vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
-