- 27 Apr, 2026 9 commits
-
-
next-js-bot[bot] authored
-
Zack Tanner authored
Stacked on https://github.com/vercel/next.js/pull/93245 Commit signing is required for anything that lands on `canary`. Our previous workflow of using a PAT to push a commit no longer works, since that would have been an unsigned commit. In #93245 we switched to an app token for release workflow steps. This continues by: - Telling Lerna to bump packages but not commit - Creating a signed commit with the staged changes via GitHub's API - Then running the publish flow Test Plan: Dry run [here](https://github.com/vercel/next.js/actions/runs/25001287978/job/73211826479) Commit [here](https://github.com/vercel/next.js/commit/3a8456a62b56615e2f8c1d1e6e7b4e14ce89e078)
-
Tobias Koppers authored
## What? Performance improvements for the turbopack-trace-server, optimizing how span events are stored, sorted, and retrieved. ## Why? When processing large traces, the trace server was spending significant time on: 1. Repeated sorting of events for each render in ExecutionOrder mode 2. Recomputing corrected self time on repeated lookups 3. Memory pressure from very large traces ## How? ### Lazy Sorting with LazySortedVec Introduces a new `LazySortedVec<T>` data structure that stores events unsorted and defers sorting until first read via `Deref`. Uses `UnsafeCell` + `Once` for thread-safe one-time sorting. This avoids repeated sorting overhead during trace ingestion. ### Pre-sorted Span Events by Start Time - `SpanEvent::Child` now stores its `start: Timestamp` alongside the index - `SpanEvent` implements `Ord` to sort by start time (with SelfTime before Child for equal timestamps) - The viewer's `ExecutionOrder` mode no longer needs to sort - events are already in order ### Cached Corrected Self Time - `SpanEvent::SelfTime` now wraps a `SpanEventSelfTime` struct containing an `OnceLock<Timestamp>` for `corrected_self_time` - The expensive tree lookup is performed once and cached for subsequent accesses - `SpanEventSelfTimeRef` provides access to the cached value via `corrected_self_time()` ### DROP_SPANS Environment Variable Adds `DROP_SPANS=<count>` env var to skip the first N spans when loading traces: - Useful for reducing memory usage with very large traces - Tracks dropped span IDs to also skip their subsequent events (End, SelfTime, etc.) - Stats output shows dropped span progress (e.g., "1000 spans, 500/1000 dropped") <!-- NEXT_JS_LLM_PR --> --------- Co-authored-by:Claude Opus 4.7 (1M context) <noreply@anthropic.com>
-
Zack Tanner authored
Moves all release workflows off of a GH PAT and uses an app with a short-lived token instead. Test Plan: Dry run [here](https://github.com/vercel/next.js/actions/runs/24934593874). However, this workflow is blocked until we figure out commit signing for the bot app. Some options: - The bot account generates a signing key and we use it in CI (not great, bypasses the app) - The org bypasses signature verification for the bot user (also not great, requires an exemption rule) - We need to rework the commit step so Lerna does not do the push, and instead trigger it via the app + GH API. This seems like the best option, will be added in a follow-up PR. Note: `create-release-branch` workflow is broken in its current form, as we will not be restoring administrator privileges to adjust environment settings. This will become a manual step in the future.
-
christopherkindl authored
The Cloudinary URL for the overlay screenshot (`assets.vercel.com/image/upload/v1645118290/docs-assets/static/docs/error-handling/overlay.png`) 404s. The line above it had a `{/* TODO UPDATE SCREENSHOT */}` comment, so this was already flagged as known-stale. Removes the broken image and its `"Here is an example of an overlay:"` intro line. The paragraph above still explains what the overlay is, so the page reads cleanly without the screenshot. If someone produces a fresh screenshot later, restoring the markdown with an updated URL is a one-line change. ### Affects - `nextjs.org/docs/pages/building-your-application/configuring/error-handling` (stable, on next stable cut) - `nextjs.org/docs/canary/pages/building-your-application/configuring/error-handling` (canary) ### Older versions The same broken URL is present in v13/v14/v15 of the docs (synced from the corresponding release tags). Backport is a separate call for maintainers. -
Hendrik Liebau authored
The error-code SWC plugin at `crates/next-error-code-swc-plugin` previously only transformed `new Error(msg)` call sites where the constructor identifier was in the hard-coded `is_error_class_name` list. Subclasses not in that list — for example `UseCacheTimeoutError`, which defines its message inside the constructor via `super('...')` and is instantiated with no arguments — went undetected, so their instances carried no `__NEXT_ERROR_CODE` at all. The plugin now also visits class declarations and expressions. When it sees `class X extends Y` where `Y` is one of the recognized Error classes, it finds the first top-level `super(arg)` call inside the constructor body, resolves the argument to a string via the existing `stringify_new_error_arg` logic (which handles string literals, template literals, string concatenations, and resolved identifier bindings), and inserts an `Object.defineProperty(this, '__NEXT_ERROR_CODE', ...)` statement immediately after the `super` call. Messages that aren't in `errors.json` yet are emitted to `cwd/.errors/<hash>.json` and consolidated by the existing `check-error-codes` build step, exactly as the call-site path already does. Classes whose `super` is nested inside an `if` or `try`, or whose only argument is a spread (`super(...args)`), are left alone. Classes that are already in `is_error_class_name` (for example `InvariantError`) now get a code assigned at both their call sites and inside their constructor body. The call-site `Object.defineProperty` runs after the constructor and therefore takes precedence at runtime, so observable behavior at those sites is unchanged. The constructor injection is defensive for any future instantiation that the call-site pass doesn't cover. `packages/next/errors.json` gains nine entries for super messages in existing Error subclasses that the plugin now captures for the first time. -
Tobias Koppers authored
## What? Adds documentation and TypeScript types for `import.meta.glob` in Turbopack, and implements additional edge cases for Vite compatibility. ### Documentation - New `## import.meta.glob` section in the [Turbopack reference page](/docs/app/api-reference/turbopack) covering: lazy/eager loading, named imports, query strings (including the object form), multiple patterns, negation, TypeScript types, and a full options table. - `import.meta.glob` row added to the Module Resolution feature table. - Migration note added to the [from-Vite guide](/docs/app/guides/migrating/from-vite) explaining that `import.meta.glob` works out of the box with Turbopack, with before/after for the deprecated `as` → `query` migration. ### TypeScript types - Added `ImportMetaGlobOptions` interface and overloaded `glob()` signatures to `ImportMeta` in `packages/next/types/global.d.ts`. - The overloads return `Record<string, unknown>` when `eager: true` is passed and `Record<string, () => Promise<unknown>>` otherwise. ### Implementation (edge cases) - **`import: '*'`** (namespace import): Treated the same as omitting the `import` option (returns the whole module namespace), matching Vite semantics. Previously would have generated broken `module["*"]` access. - **`query` as object literal**: `{ query: { bar: 'foo', raw: true } }` is now supported. Keys and values are URL-encoded and joined into a query string (`?bar=foo&raw=true`). - **Stricter option validation**: A non-object-literal second argument (e.g. `import.meta.glob('./*.js', 'eager')`) is now a compile-time error instead of a warning, since the options cannot be safely defaulted. ### Tests - Execution tests for new features: namespace `import: '*'`, query object, combining query with negation, explicit dotfile patterns. - New `import-meta-glob-errors` execution test with issue snapshots covering: too many arguments, non-string pattern, and non-object options argument. ## Why? 1. The feature shipped in #92640 but had no user-facing documentation and no TypeScript types. 2. Several Vite-compatible edge cases were not handled: namespace imports (`import: '*'`) and query objects. These gaps would cause subtle behavioral differences for users migrating from Vite. 3. Option validation was too lenient — invalid second arguments fell through to defaults silently. ## How? ### Docs & types - `docs/01-app/03-api-reference/08-turbopack.mdx` — new section, table row, TypeScript subsection - `docs/01-app/02-guides/migrating/from-vite.mdx` — migration note - `packages/next/types/global.d.ts` — `ImportMetaGlobOptions` + `ImportMeta.glob()` overloads ### Implementation - `turbopack/crates/turbopack-ecmascript/src/references/import_meta_glob.rs`: - `parse_import_meta_glob()`: `import: '*'` normalized to `None`; query object parsing via `urlencoding::encode()`; non-object options argument now emits an error and returns `None`. - `turbopack/crates/turbopack-ecmascript/Cargo.toml`: added `urlencoding` workspace dep. Note: dotfile/dot-directory filtering is not needed in `import.meta.glob` itself — the underlying `Glob` pattern engine and `read_glob_internal` already handle dotfile semantics correctly (explicit `./.foo/*.js` matches, wildcards include them). ### Tests - `turbopack-tests/tests/execution/turbopack/resolving/import-meta-glob/` — new cases for `import: '*'`, query object, query + negation, explicit dotfile pattern, wildcard including dotfiles - `turbopack-tests/tests/execution/turbopack/resolving/import-meta-glob-errors/` — new test suite for fatal parse errors with issue snapshots ### Checklist - [x] `pnpm prettier-fix` / `cargo fmt` run - [x] Documentation follows the [docs contribution guide](https://nextjs.org/docs/community/contribution-guide) - [x] Execution tests pass (`cargo test -p turbopack-tests --test execution -- "import_meta_glob"`) - [x] `cargo clippy` clean - [x] `pnpm --filter=next types` passes <!-- NEXT_JS_LLM_PR --> --------- Co-authored-by:Tobias Koppers <sokra@users.noreply.github.com> Co-authored-by:
Claude <noreply@anthropic.com>
-
Tobias Koppers authored
[rust-deps] Update bytes, crc32fast, memchr, pin-project-lite, quote, rand, regex, ringmap, roaring (#93197) ### What? Updates Rust dependencies to their latest versions: | Crate | From | To | |-------|------|-----| | bytes | 1.1.0 | 1.11.1 | | crc32fast | 1.4.2 | 1.5.0 | | memchr | 2.7.4 | 2.8.0 | | pin-project-lite | 0.2.9 | 0.2.17 | | quote | 1.0.23 | 1.0.45 | | rand | 0.10.0 | 0.10.1 | | regex | 1.10.6 | 1.12.3 | | ringmap | 0.2.3 | 0.2.5 | | roaring | 0.10.10 | 0.11.4 | ### Why? Keep dependencies up to date with latest bug fixes, performance improvements, and security patches. ### How? Version bumps in `Cargo.toml` with corresponding `Cargo.lock` updates. <!-- NEXT_JS_LLM_PR -->
-
Sebastian "Sebbie" Silbermann authored
-
- 25 Apr, 2026 5 commits
-
-
Andrew Clark authored
In dev with cacheComponents, the instant-nav prefetch for a dynamic route resolved the slug into the cached shell instead of returning the generic fallback, so `params` never suspended under a locked instant scope. Existing e2e coverage missed this because the fixture's dynamic-params page had `generateStaticParams` defined. That populates the dev prerender manifest and masks the bug — the broken path is the one where no `generateStaticParams` is defined. The regression test uses a new `ungenerated-params/[slug]` fixture that leaves it out.
-
Sebastian "Sebbie" Silbermann authored
-
Sebastian "Sebbie" Silbermann authored
-
Sebastian "Sebbie" Silbermann authored
-
Andrew Clark authored
The Instant Navigation Testing API simulates what a user would see on an arbitrarily slow connection — like an infinitely slow network — when the app is at rest and the prefetch cache is completely warm. It works by blocking any dynamic RSC data fetches until the end of the testing scope (i.e. the callback passed to instant()). It's designed to test the behavior of data fetched by Next.js, via a Server Component. So currently, it does not affect the behavior out-of-band client fetches — e.g. fetch('/api/...') in useEffect or an external data fetching library. Those requests proceed without being blocked by the `instant()` scope. But this is misleading for testing purposes, because it implies that client-side data fetches are not affected by slow network conditions. To address this, this PR overrides the global `fetch` API and blocks out-of-band client fetches until the lock is released. The change also impacts the behavior of the Instant DevTools panel (since both tools use the same underlying mechanism). The change only affects environments where the Instant Navigation Testing API is enabled. It has no impact on live production behavior. It does not account for other sources of I/O, like images, scripts, fonts, etc. <!-- NEXT_JS_LLM_PR -->
-
- 24 Apr, 2026 19 commits
-
-
Luke Sandberg authored
Reverts vercel/next.js#93071 This breaks our use of lerna, lerna uses npm-package-arg to parse package.json files and cannot resolve `catalog` references
-
Luke Sandberg authored
It's dead
-
Zack Tanner authored
Needs write to comment on PR. x-ref: https://github.com/vercel/next.js/actions/runs/24914306362/job/72962981110
-
Sebastian "Sebbie" Silbermann authored
-
Zack Tanner authored
- Add a workflow_run reporter that posts PR test/stats comments using `GITHUB_TOKEN`. - Upload PR metadata artifacts from `build-and-test` and `Generate Stats` so the reporter can safely resolve the target PR - Move stats/test comment posting out of the external webhook/PAT path while preserving the existing comment format This means the test comment won't incrementally update as tests fail, it'll just post once at the end, but that's a reasonable tradeoff to not having to worry about a webhook.
-
Sebastian "Sebbie" Silbermann authored
-
Sebastian "Sebbie" Silbermann authored
-
Sebastian "Sebbie" Silbermann authored
-
Niklas Mischkulnig authored
`resolve_origin.get_inner_asset` showed up in Luke's statistics at a very high place. But in reality, there are only 1-3 modules per page that have any inner assets (the templates, and the edge wrapper modules). `resolve_origin.get_inner_asset` is in the hottest hot path (resolving references), so let's simply move this logic into the EcmascriptModuleAsset itself. Behavioral differences to before: - only works with static ESM `import`s, dynamic `import()`, `require`, `require.resolve`. But these are the only places that currently use it anyway. ``` 0d9738112f mischnic/remove-get-inner-asset pnpm next build --experimental-build-mode=compile 353.40s user 52.96s system 748% cpu 54.265 total pnpm next build --experimental-build-mode=compile 349.42s user 53.84s system 744% cpu 54.198 total pnpm next build --experimental-build-mode=compile 352.42s user 54.46s system 741% cpu 54.874 total 3cb77c84 canary pnpm next build --experimental-build-mode=compile 367.91s user 58.06s system 726% cpu 58.672 total pnpm next build --experimental-build-mode=compile 362.97s user 57.68s system 746% cpu 56.379 total pnpm next build --experimental-build-mode=compile 364.59s user 57.01s system 724% cpu 58.167 total ```
-
Joseph authored
Retaking the example clean up cycle.
-
Sebastian "Sebbie" Silbermann authored
-
Niklas Mischkulnig authored
We have options and variable length lists. Why do we need a separate function for every combination?
-
Tobias Koppers authored
### What? Updates the `tracing` crate and its related dependencies to their latest versions: - `tracing`: 0.1.37 → 0.1.44 - `tracing-attributes`: 0.1.30 → 0.1.31 - `tracing-core`: 0.1.34 → 0.1.36 ### Why? Keep Rust dependencies up to date with security patches and performance improvements. ### How? Updated the version specification in `Cargo.toml` and regenerated `Cargo.lock`. <!-- NEXT_JS_LLM_PR -->
-
Tobias Koppers authored
### What? Updates the serde family of crates to their latest versions: - `serde`: 1.0.217 → 1.0.228 - `serde_json`: 1.0.138 → 1.0.149 - `serde_path_to_error`: 0.1.16 → 0.1.20 - `serde_qs`: 0.13.0 → 1.1.1 - `serde_with`: 3.12.0 → 3.18.0 ### Why? Keep dependencies up to date with bug fixes and performance improvements. ### How? Updated version constraints in `Cargo.toml` and ran `cargo update` to regenerate the lockfile. <!-- NEXT_JS_LLM_PR -->
-
Niklas Mischkulnig authored
I'm moving all of the export-related logic into `EvalContext` (and thus `ImportMap`) so that `VarGraph` is only needed for computing the references, and not the exports.
-
Tobias Koppers authored
### What? Adds a new environment variable `NEXT_TURBOPACK_TRACING_PATH` that lets users specify the full output path (including filename) for the Turbopack trace file. ### Why? Some users need to control where the `trace-turbopack` file is written — for example, to redirect it outside the project directory, to a shared volume, or to a custom filename. Previously the path was hardcoded to `<project>/.next-profiles/trace-turbopack` with no override mechanism. ### How? When `NEXT_TURBOPACK_TRACING` is set (tracing is enabled) and `NEXT_TURBOPACK_TRACING_PATH` is also set, the trace is written to the specified path instead of the default: - **Absolute paths** are used as-is. - **Relative paths** are resolved against the process CWD. - The **parent directory is auto-created** recursively (equivalent to `mkdir -p`), so pointing to a non-existent subdirectory works without manual setup. - Setting `NEXT_TURBOPACK_TRACING_PATH` alone (without `NEXT_TURBOPACK_TRACING`) has no effect — tracing is not enabled by it. - The "Trace output will be written to …" message reflects the resolved path. The change is confined to `crates/next-napi-bindings/src/next_api/project.rs`. **Example:** ```sh NEXT_TURBOPACK_TRACING=overview \ NEXT_TURBOPACK_TRACING_PATH=/tmp/my-project-trace \ next dev ``` <!-- NEXT_JS_LLM_PR --> Co-authored-by:
Tobias Koppers <sokra@users.noreply.github.com> Co-authored-by:
Claude <noreply@anthropic.com>
-
Tobias Koppers authored
### What? Fix `FilterLayer::max_level_hint` in `turbopack-trace-utils` to return the most verbose `LevelFilter` across per-target configs instead of the least verbose one. ### Why? `tracing`'s `Subscriber` uses `max_level_hint` to short-circuit event dispatch globally: any event whose level is more verbose than the hint is dropped before `enabled()` is consulted. The previous implementation returned `self.config.values().copied().min()`, i.e. the *least* verbose configured level. As soon as any target was filtered to a low verbosity (e.g. `WARN`), events at more verbose levels (`INFO`/`DEBUG`/`TRACE`) were discarded for *all* targets, even those whose own per-target config would have allowed them. ### How? Swap `min()` → `max()` in `FilterLayer::max_level_hint` so the hint reflects the most verbose level any configured target could enable. Per-target filtering in `enabled()` is unchanged and continues to enforce the correct level for each target. <!-- NEXT_JS_LLM_PR --> --------- Co-authored-by:vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
-
Zack Tanner authored
Pins these docker dependencies. Follow-up from: https://github.com/vercel/next.js/pull/93164#discussion_r3135035714 x-ref: https://github.com/rust-cross/rust-musl-cross/pkgs/container/rust-musl-cross/741104753?tag=x86_64-unknown-linux-musl https://github.com/rust-cross/rust-musl-cross/pkgs/container/rust-musl-cross/741104508?tag=aarch64-unknown-linux-musl
-
Zack Tanner authored
## Summary Switch CI from self-hosted runners to GitHub-hosted runners and fix the follow-up issues that showed up once the hosted jobs were exercised. ## Changes - Move Linux workflows onto `ubuntu-latest-16-core-oss`, Windows workflows onto `windows-latest-8-core-oss`, and the native mac release lane onto `macos-15-intel`. - Update the reusable build workflow to work in hosted environments by relying on `runner.os` instead of label string matching, and by removing the hardcoded `/home/runner` `fnm` path. - Make Turbo/sccache configuration explicit for hosted runners: - unify on `vtest314-next-adapter-e2e-tests` - pass `TURBO_TOKEN` via workflow env/secrets instead of assuming runner-level env - switch Turbo cache mode to `local:rw,remote:rw` so jobs still have local cache behavior when remote cache is unavailable - Update the `sccache` action defaults/docs to use the hosted-runner secret setup (`TURBO_TOKEN`) instead of the old self-hosted token wiring. - Make Datadog reporting fail open so missing `DATA_DOG_API_KEY` does not block CI. - Fix the CLI reserved-port test so it asserts Next’s own `-p 1` validation instead of failing earlier on hosted Linux due to privileged-port binding. - Replace the live `musl.cc` dependency in `native-builder.Dockerfile` with musl sysroots imported from GHCR-hosted `rust-musl-cross` images, keeping the existing `/opt/*-cross` layout used by the Linux native build scripts. - Fix the macOS native build workaround s so it applies to all *-apple-darwin targets based on the Cargo target OS rather than the host architecture, which avoids napi-build injecting the unsupported -Wl linker arg when @next/swc is linked with rust-lld on hosted mac runners. Test Plan: - This PR's CI - This [build_and_deploy](https://github.com/vercel/next.js/actions/runs/24865715983/job/72801225722) job running on every arch
-
- 23 Apr, 2026 1 commit
-
-
Jimmy Lai authored
## What? Adds contributor-facing guidance for the new signed-commit requirement. - adds a `Signed commits` section to `contributing.md` - adds a short signed-commit note to the PR template - clarifies that a `Signed-off-by` line is not enough ## Why? As signed commits become required, contributors need a clear explanation in the repo and at PR time so they know what will be enforced and how to recover from unsigned commits. ## How? Documents the requirement in the main contribution guide and repeats the key action items in the PR checklist. ## Testing - docs-only change - verified with local readback and diff review <!-- NEXT_JS_LLM_PR -->
-
- 22 Apr, 2026 3 commits
-
-
Zack Tanner authored
Remove labels that we are no longer maintaining.
-
Andy Wooldridge authored
### What? fixes #74882 The `use cache` directive does not revalidate in the background while serving (not expired) stale data. For the static pages, the whole page is blocked during revalidation, and fresh data is fetched served. While I don't agree with this, as it is just a duplication of the expire behaviour, this is documented as intended in the comments in the code. For the dynamic pages, when the data is flagged for revalidation, the stale data is blocked while fresh data is fetched. Once the fresh data is fetched, the function returns the stale data. On refreshing, the fresh data is served. This is the worst of both worlds, as we are still waiting for fresh data, and then seeing the stale data. In both cases there is no background revalidation of data, leading to slow, unresponsive pages. I have an example app showing this behaviour here: https://github.com/awo00/nextjs-use-cache-revalidate ### Why? In the `use-cache-wrapper`, the `generateCacheEntry()` function is awaited during revalidation which is blocking the stale data being returned. ### How? Removing the await allows the stale data to be returned faster. --------- Co-authored-by:
Hendrik Liebau <mail@hendrik-liebau.de>
-
Zack Tanner authored
Fixes a type error on canary after merging two PRs that touched the same test.
-
- 21 Apr, 2026 3 commits
-
-
Luke Sandberg authored
### What? Every `pnpm test-*` / `pnpm testonly-*` script in the root `package.json` is now a single direct invocation of a new `scripts/run-jest.sh` helper instead of chaining through several `pnpm run` + `cross-env` layers. ### Why? Each hop through `pnpm run` / `cross-env` spins up its own Node process and takes a few hundred milliseconds before anything useful happens. For example, `pnpm test-dev-turbo` used to walk through five layers: ``` test-dev-turbo -> pnpm run with-turbo pnpm test-dev-inner (cross-env IS_TURBOPACK_TEST=1) -> pnpm test-dev-inner (cross-env NEXT_TEST_MODE=dev) -> pnpm testheadless (cross-env HEADLESS=true) -> pnpm testonly -> jest --runInBand ``` #### Measured overhead (same machine, same stubbed jest invocation — `jest --version`) | Chain | Layers | Median (ms) | Range (ms) | |---|---|---|---| | `jest --version` (baseline, direct) | 1 | 80 | 75–89 | | `pnpm test-dev-turbo --version` (**new**) | `pnpm → bash → jest` | 448 | 435–493 | | `pnpm test-dev-turbo --version` (**old**) | `pnpm → cross-env → pnpm → cross-env → pnpm → cross-env → pnpm → jest` | 2494 | 2462–2512 | That's **~2 seconds per test invocation** shaved off, and ~85% reduction in wrapper overhead (from ~2414 ms to ~368 ms). The remaining ~368 ms is essentially just one `pnpm run` startup, which is unavoidable while we keep the `pnpm test-*` entry points. Real-world impact: for a ~72 s e2e test run this is ~3%, but for fast unit-test files (often <5 s) this is closer to 30-40%, and it adds up quickly in CI jobs that shell out to these scripts in a loop. ### How? - New `scripts/run-jest.sh` parses named flags and `exec`s jest directly: - `--mode=<dev|start|deploy>` → sets `NEXT_TEST_MODE` - `--bundler=<webpack|turbo|rspack>` → sets `IS_WEBPACK_TEST=1` / `IS_TURBOPACK_TEST=1` / `NEXT_RSPACK=1 NEXT_TEST_USE_RSPACK=1` - `--experimental` → sets `__NEXT_CACHE_COMPONENTS=true __NEXT_EXPERIMENTAL_APP_NEW_SCROLL_HANDLER=true` - `--headless` → sets `HEADLESS=true` - `--` terminates flag parsing; everything after is forwarded verbatim to jest so existing workflows like `pnpm test-dev-turbo path/to/foo.test.ts -t "pattern"` keep working. - Every `test-*` / `testonly-*` entry in `package.json` (including `testheadless`) now reads like `scripts/run-jest.sh --mode=dev --bundler=turbo --headless --`. No more `pnpm run` / `cross-env` indirection at the top level. - Removed nine unused internal intermediates (`test-dev-inner`, `test-dev-experimental-inner`, `test-start-inner`, `test-start-experimental-inner`, `test-deploy-inner`, `testonly-dev-inner`, `testonly-start-inner`, `testonly-deploy-inner`, `test-inner`). These were only called by other package.json scripts and not referenced anywhere else in the repo. - Kept `testonly`, `testheadless`, and all public `test-*` / `testonly-*` names so `AGENTS.md`, `contributing/core/testing.md`, `.conductor/`, and `.agents/skills/` work unchanged. - The `with-webpack`, `with-turbo`, `with-rspack`, and `with-experimental` prefix scripts remain for ad-hoc use; they are just no longer in the hot path of the test scripts. - `scripts/run-jest.sh` invokes a bare `jest`, which resolves via `$PATH` (pnpm prepends `node_modules/.bin/` when running a package script). The helper is documented as only supported when invoked through a package runner. ### Verification Ran a small e2e test through the new chain in both dev+turbopack and start+webpack modes. Output confirms env vars propagate correctly (`PASS Turbopack ...` / `PASS webpack ...`, plus `pnpm next --turbopack` vs `pnpm next start` in the logs): ``` pnpm test-dev-turbo test/e2e/app-dir/_allow-underscored-root-directory/... -> PASS Turbopack ... 3 passed pnpm test-start-webpack test/e2e/app-dir/_allow-underscored-root-directory/... -> PASS webpack ... 3 passed ``` CI is unaffected: every workflow invokes `node run-tests.js ...` directly, never through these pnpm scripts. <!-- NEXT_JS_LLM_PR --> -
Luke Sandberg authored
## What Tightens the value-type persistence API and sets the table for a future eviction policy. Two user-visible changes on the `#[turbo_tasks::value(...)]` macro: - **`serialization = "none"` → `serialization = "skip"`** — imperative ("skip persisting") instead of descriptive. Making it clear that it isn't that we are missing a feature but rather that we are choosing to not persist (of course persisting might be impossible but that is generally rare) - **New `evict = "always" | "last" | "never"` attribute** — replaces the old overloaded `"none"` semantic. Only valid with `serialization = "skip"`. Defaults to `"always"`. Internally this collapses `persistent_cell_data` + `transient_cell_data` into one `cell_data` map and replaces the old `bincode: Option<(enc, dec)>` field with a four-variant `ValueTypePersistence` enum. Eviction machinery itself is a follow-up PR; this PR just gives each value type a precise, queryable persistence/eviction descriptor. ## Why break out a new parameter? `serialization = "none"` on canary conflated three different intents: 1. **Cheap recomputable outputs** (SWC ASTs, codegen `Rope`s) — fine to evict, recompute is cheap. 2. **Expensive recomputable outputs** (WASM modules, Node process pools) — re-derivable but costly. 3. **Session-scoped state** (`State<>` cells, `Arc<Mutex<_>>` dedup histories) — can't be recomputed without losing accumulated mutations. They all produced identical runtime behavior (stored in transient_cell_data), so eviction can't tell them apart. The fix is two orthogonal attributes: ```rust // A cheap skip — default evict = "always" #[turbo_tasks::value(serialization = "skip")] // Expensive recompute — evict last under pressure #[turbo_tasks::value(serialization = "skip", evict = "last")] // Session-scoped state — never evict #[turbo_tasks::value(serialization = "skip", evict = "never")] ``` The macro rejects `evict` on any other `serialization` mode. ## `ValueTypePersistence` enum Replaces `ValueType.bincode: Option<(enc, dec)>`: ```rust pub enum ValueTypePersistence { Persistable(AnyEncodeFn, AnyDecodeFn<SharedReference>), // auto, custom SkipPersist { expensive: bool }, // skip (+ evict = last) HashOnly, // hash SessionStateful, // skip + evict = never } ``` The existing `"hash"` mode gets its own `HashOnly` variant rather than being folded into `SkipPersist`, which lets the backend gate its hash-writing and hash-comparison paths precisely. ## Unified `cell_data` storage `persistent_cell_data: AutoMap<CellId, TypedSharedReference>` + `transient_cell_data: AutoMap<CellId, SharedReference>` collapse into `cell_data: CellData`. `CellData` is a newtype over `AutoMap<CellId, SharedReference>` with a custom bincode impl that filters non-`Persistable` entries at encode time. This removes the `is_serializable_cell_content: bool` parameter that was threading through ~14 read/write call sites. Uses `SharedReference` instead of `TypedSharedReference` — `CellId` already carries the `ValueTypeId`. ## Annotation sweep All prior `serialization = "none"` sites move to either `serialization = "skip", evict = "never"` or `serialization = "skip", evict = "last"` based on a per-site audit. Summary: **`evict = "last"` (6 sites)** — re-derivable but expensive: - `SwcPluginModule`, `EvaluatePool`, `ChildProcessPool`, `WorkerThreadPool`, `EffectInstance`, `Effects` **`evict = "never"` (2 sites)** — interior-mutable state accumulated across the session: - `ConsoleUi` (`Arc<Mutex<SeenIssues>>`), `VersionState` (`State<VersionRef>` with HMR invalidators) The distinguishing rule: `evict = "never"` only when the value holds interior mutability accumulated across the session. Everything else can be re-derived (possibly expensively) by re-running the producing task. ## Follow-ups (separate PRs) - Wire an eviction policy that consumes `ValueTypePersistence` — respects `SessionStateful` (never evict), prefers cheap `SkipPersist` over `expensive: true` ones. Either as part of #91790 or afterwards depending on when things land <!-- NEXT_JS_LLM_PR --> -
Will Binns-Smith authored
### What? Two behaviour changes to the rage-restart detection in `next dev`, plus a refactor of the git helper code: 1. **Lower the rage-restart threshold from 120s to 90s.** The previous window was too generous; 90 s is a better match for the workflow of stopping and immediately restarting the dev server. 2. **Don't count a restart as a rage-restart if the git branch changed.** A common workflow is: stop the dev server, `git checkout <other-branch>`, restart. That sequence has nothing to do with frustration — it's intentional. The dev state file now records the current git branch on shutdown, and on startup the recorded branch is compared to the current one. If they differ the restart is not flagged. If either branch is unknown (detached HEAD, not a git repo, etc.) the comparison is skipped and we fall back to time-only detection, preserving the existing behaviour. ### Why? The rage-restart signal is meant to detect genuine frustration with the dev server (e.g. it's hanging or erroring on startup). Switching branches is an intentional, deliberate action that happens to look the same from a pure timing perspective. Capturing it as rage-restart pollutes telemetry and could trigger unwanted recovery behaviour. The git helper consolidation removes duplicated `spawnSync` / `execSync` calls spread across unrelated files, centralises the `VERCEL_GIT_*` env-var fallback logic, and makes it easy to add further git queries in one place. ### How? - `writeDevState()` in `next-dev.ts` now calls `getGitBranch(dir)` and stores the result under a `gitBranch` key in the dev state file (omitted when the branch is unknown). - On startup, after reading the dev state file, the stored `gitBranch` is compared to the freshly-read `getGitBranch(dir)`. `isRageRestart` is only set when the branch either hasn't changed or couldn't be determined. - `packages/next/src/lib/helpers/git.ts` provides `gitExec()` (private), `getGitBranch()`, and `getGitCommit()`. It replaces the deleted `get-git-branch.ts` and the open-coded `child_process.spawnSync` calls in `trace-uploader.ts`. <!-- NEXT_JS_LLM_PR --> --------- Co-authored-by:
Will Binns-Smith <wbinnssmith@users.noreply.github.com> Co-authored-by:
Claude <noreply@anthropic.com>
-