1. 03 Apr, 2026 11 commits
    • nextjs-bot's avatar
      v16.2.1-canary.19 · 28096d36
      nextjs-bot authored
      28096d36
    • Aurora Scharff's avatar
      fix: add @deprecated annotation to experimental.useCache (#92316) · 739299d3
      Aurora Scharff authored
      ### What?
      
      Add a `@deprecated` JSDoc annotation to `experimental.useCache` in
      `config-shared.ts`, pointing to `cacheComponents: true` as the
      successor.
      
      ### Why?
      
      `experimental.cacheComponents` already has `@deprecated use top-level
      cacheComponents instead`, but `experimental.useCache` has no deprecation
      notice despite `cacheComponents: true` being the documented successor.
      This causes both developers and AI coding agents to use the old flag,
      since nothing in the type definitions signals it's deprecated. IDEs and
      agents rely on JSDoc annotations for guidance.
      
      ### How?
      
      Replace the existing JSDoc comment on `experimental.useCache` with
      `@deprecated use top-level cacheComponents instead`, matching the
      existing pattern on `experimental.cacheComponents`.
      
      ## PR checklist (Fixing a bug)
      
      - One-line JSDoc change, no tests needed
      
      Made with [Cursor](https://cursor.com)
      739299d3
    • Zack Tanner's avatar
      ci: remove deploy examples workflow from build-and-deploy (#92324) · d5f479c1
      Zack Tanner authored
      We don't need to deploy a single image component example every time
      `build_and_deploy` runs. If something about this example changes, it can
      be manually re-deployed.
      d5f479c1
    • Luke Sandberg's avatar
      Revert "simplify session dependent tasks and add TTL support (#91729)" (#92320) · 6160d0db
      Luke Sandberg authored
      This is causing OOMs in some applications running with a persistent cache
      
      See discussion: https://vercel.slack.com/archives/C03EWR7LGEN/p1775159630054759
      
      The issue appears to be invalidating the chunk graph in an odd way that causes us to allocate an ~infinite number of error strings
      6160d0db
    • Zack Tanner's avatar
      ci: fix stats action (#92325) · 392d02ae
      Zack Tanner authored
      We recently re-imaged the self-hosted Linux runners and it now hits
      `ERR_PNPM_EXDEV` when pnpm copies packages between its default store and
      the temp stats workspace. Keeping both under the same temp root avoids
      the cross-filesystem copy failure.
      392d02ae
    • Tim Neutkens's avatar
      Move streamToUint8Array back to node-web-streams-helper.ts (#92263) · ff7cd1bf
      Tim Neutkens authored
      ## What?
      
      Fixes the case where having React 18 installed fails the build because
      react-dom gets imported from stream-ops. #90500 moved the
      `streamToUint8Array` from node-web-streams-helper to stream-ops. This
      moves the function back to where it was before.
      ff7cd1bf
    • Zack Tanner's avatar
      Ensure app-page reports stale ISR revalidation errors via onRequestError (#92282) · 9cb20484
      Zack Tanner authored
      Note: the change is mostly whitespace. Recommend reviewing w/o
      whitespace
      [here](https://github.com/vercel/next.js/pull/92282/changes?w=1).
      
      For App Router pages using time-based ISR, a stale cached response can
      be returned before background revalidation finishes. If that background
      revalidation later throws, the error does not bubble back through the
      normal top-level `app-page` request catch. Instead, the response cache
      has already resolved the request and later logs the failure internally.
      
      When an error happens while rendering an app router page, and the entry
      is stale, we now explicitly await `routeModule.onRequestError(...)`
      before rethrowing.
      
      This copies similar handling in pages router:
      https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/server/route-modules/pages/pages-handler.ts#L438-L460
      
      and route handlers:
      
      https://github.com/vercel/next.js/blob/daca04d09bf9aaee9e1c63324166985b643e9844/packages/next/src/build/templates/app-route.ts#L407-L409
      9cb20484
    • Luke Sandberg's avatar
      [turbopack] optimize RcStr parsing (#91773) · 678a4aa9
      Luke Sandberg authored
      `RcStr` has 3 internal forms
       * `INLINE` meaning it is small enough that the bytes are stored inline (7 bytes)
       * `STATIC` meaning it was allocated by `rcstr!` and is stored in a `static` item somewhere
       * `DYNAMIC` meaning it is stored in an `Arc`
      
      The nice thing is that `INLINE` and `STATIC` are not ref-counted which optimizes clones.  The unfortunate thing is that serialization round trips partially defeat these optimizations.  To fix that we do two things
      
      1. decode to a `&str` instead of a `String` so we can defer the allocation to if/when we select the `DYNAMIC` format
      2. store all static strings in an inventory managed hashtable (lazily constructed) so we can match against them when deserializing them
      
      This allows us to avoid temporary allocations during decoding for the `inline` case and completely eliminate them for the static case.  The dynamic case simply pays the cost of probing the static hash table and defers the allocation to slightly later.  The hash probe is not free but the table is small ~1500 entries, so this overhead should be negligible
      
      
      Also i needed to update our `wasm-bindgen` versions to workaround https://github.com/wasm-bindgen/wasm-bindgen/issues/4446
      678a4aa9
    • Aurora Scharff's avatar
      Add view transitions eval (agent-043) (#92260) · fb3ebba6
      Aurora Scharff authored
      ## Summary
      
      - Adds `agent-043-view-transitions`, a new eval that tests whether
      agents can add React View Transitions to a Next.js product gallery app
      - Starter app is a simple product list/detail gallery with Suspense
      boundaries, no view transitions
      - EVAL.ts checks 8 patterns: `viewTransition` config flag,
      `ViewTransition` imported from `react`, shared element `name` props,
      `transitionTypes` on Link, Suspense enter/exit animations,
      `default="none"` isolation, `prefers-reduced-motion` CSS, and
      `::view-transition-*` CSS pseudo-elements
      
      ## Test plan
      
      - [x] Starter app builds with `next build`
      - [x] All 8 EVAL.ts tests fail on unmodified starter (no false
      positives)
      - [x] All 8 EVAL.ts tests pass on a correct golden solution
      - [x] Golden solution builds with `next build` (viewTransition
      experiment detected)
      - [x] Commit passes lint-staged (prettier + eslint)
      fb3ebba6
    • Tobias Koppers's avatar
      Add MCP `get_compilation_issues` tool and NAPI method (#92062) · 41839289
      Tobias Koppers authored
      ### What?
      
      Adds a new \`get_compilation_issues\` MCP tool (and the underlying
      \`projectGetAllCompilationIssues\` NAPI method) that returns all
      compilation issues from all routes in a single call.
      
      **New files:**
      - \`crates/next-napi-bindings/src/next_api/project.rs\` —
      \`project_get_all_compilation_issues\` NAPI function +
      \`get_all_compilation_issues_operation\` /
      \`get_all_compilation_issues_inner_operation\` turbo-tasks operations
      - \`packages/next/src/server/mcp/tools/get-compilation-issues.ts\` — MCP
      tool implementation
      -
      \`packages/next/src/server/mcp/tools/utils/format-compilation-issues.ts\`
      — output formatter
      -
      \`test/development/mcp-server/mcp-server-get-compilation-issues.test.ts\`
      — e2e test
      - \`test/development/mcp-server/fixtures/compilation-errors-app/\` —
      fixture app with three routes (valid page, missing-module error, syntax
      error)
      
      **Modified files:**
      - \`packages/next/src/build/swc/generated-native.d.ts\` + \`types.ts\` +
      \`index.ts\` — expose the new NAPI method
      - \`packages/next/src/server/mcp/get-or-create-mcp-server.ts\` —
      register the new tool, accept \`getTurbopackProject\` option
      - \`packages/next/src/server/dev/hot-reloader-turbopack.ts\` — pass
      \`project\` to MCP middleware
      - \`packages/next/src/telemetry/events/build.ts\` — add
      \`'mcp/get_compilation_issues'\` to the \`McpToolName\` union
      
      ### Why?
      
      The existing MCP tools require a browser session (and thus a specific
      route to be rendered) to surface compilation errors.
      \`get_compilation_issues\` works without a browser session and covers
      all routes proactively — useful for AI coding agents that want to check
      for errors across the whole app before trying to render a page.
      
      ### How?
      
      **NAPI layer:**  
      \`project_get_all_compilation_issues\` calls a two-level turbo-tasks
      operation pair:
      
      1. \`get_all_compilation_issues_inner_operation\` — iterates all
      endpoint groups via \`project.get_all_endpoint_groups(false)\` and calls
      \`endpoint_group.module_graphs().as_side_effect()\` on each. This builds
      the module graph (resolution + transformation) for every entrypoint
      without chunking, emitting, or code generation. Issues are emitted as
      turbo-tasks collectables.
      
      2. \`get_all_compilation_issues_operation\` — wraps the inner op in
      \`strongly_consistent_catch_collectables\` to harvest
      issues/diagnostics/effects, then returns an \`OperationResult\`.
      
      > **Why not \`project.whole_app_module_graphs()\`?**  
      > \`whole_app_module_graphs()\` calls \`drop_issues()\` in development
      mode to prevent every per-route HMR subscription from seeing all global
      issues. Calling it here would return zero issues in dev. Per-endpoint
      \`module_graphs()\` calls don't have this suppression.
      
      **Output formatting (\`format-compilation-issues.ts\`):**  
      The raw Turbopack wire types are transformed before being returned to
      MCP consumers:
      
      - **StyledString → plain string**: \`title\`, \`description\`, and
      \`detail\` are \`StyledString\` union trees (recursive \`{type, value}\`
      objects). These are flattened to plain strings —
      \`text\`/\`code\`/\`strong\` variants return their \`.value\` directly,
      \`line\` joins with \`""\`, \`stack\` joins with \`"\n"\`.
      - **ANSI codes stripped**: \`codeFrame\` is a pre-rendered string from
      the Rust NAPI layer that contains ANSI terminal colour codes. These are
      stripped via \`next/dist/compiled/strip-ansi\`.
      - **1-indexed source positions**: Turbopack's \`SourcePos\` is 0-indexed
      for both \`line\` and \`column\`. The formatter adds \`+1\` to each so
      consumers get the conventional editor-style 1-indexed values.
      - **Deduplication**: the same issue can surface from multiple endpoints
      during the module graph traversal. Issues are deduplicated by a
      \`severity|filePath|title|startLine:startCol\` key.
      - **No diagnostics**: Turbopack diagnostics are internal telemetry
      (\`EVENT_BUILD_FEATURE_USAGE\` feature-adoption counters). They are not
      actionable for the user, so the \`diagnostics\` field is omitted
      entirely from the response.
      
      **MCP tool (\`get_compilation_issues\`):**  
      Calls \`project.getAllCompilationIssues()\`, passes the issues through
      \`formatCompilationIssues()\`, and returns \`{ issues: FormattedIssue[]
      }\` as JSON. Works without a browser session.
      
      **Test:**  
      A fixture app with three routes (valid \`app/page.tsx\`,
      \`app/missing-module/page.tsx\` importing a non-existent package,
      \`app/syntax-error/page.tsx\` with unclosed JSX) is used to verify:
      1. The tool returns a result without any browser session
      2. Module-not-found errors are detected
      3. Syntax errors are detected
      4. Issues include \`severity\`, \`title\`, \`filePath\` metadata — all
      as plain strings (not StyledString objects)
      
      e2e tests: added —
      \`test/development/mcp-server/mcp-server-get-compilation-issues.test.ts\`
      
      ---------
      Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      41839289
    • Tobias Koppers's avatar
      turbo-tasks-backend: stability fixes for task cancellation and error handling (#92254) · be3ee02b
      Tobias Koppers authored
      ### What?
      
      Bug fixes and a refactoring in `turbo-tasks-backend` targeting stability
      issues that surface when filesystem caching is enabled:
      
      1. **Preserve `cell_type_max_index` on task error** — when a task fails
      partway through execution, `cell_counters` only reflects the
      partially-executed state. Previously, `cell_type_max_index` was updated
      from these incomplete counters, which removed entries for cell types not
      yet encountered. This caused `"Cell no longer exists"` hard errors for
      tasks that still held dependencies on those cells. The fix skips the
      `cell_type_max_index` update on error, keeping it consistent with the
      preserved cell data (which already wasn't cleared on error).
      
      This bug manifested specifically with `serialization = "hash"` cell
      types (e.g. `FileContent`), where cell data is transient and readers
      fall back to `cell_type_max_index` to decide whether to schedule
      recomputation.
      
      2. **Fix shutdown hang and cache poisoning for cancelled tasks** — three
      related fixes for tasks cancelled during shutdown:
      - `task_execution_canceled` now drains and notifies all
      `InProgressCellState` events, preventing `stop_and_wait` from hanging on
      foreground jobs waiting on cells that will never be filled.
      - `try_read_task_cell` bails early (before calling `listen_to_cell`)
      when a task is in `Canceled` state, avoiding pointless listener
      registrations that would never resolve.
      - Cancelled tasks are marked as session-dependent dirty, preventing
      cache poisoning where `"was canceled"` errors get persisted as task
      output and break subsequent builds. The session-dependent dirty flag
      causes the task to re-execute in the next session, invalidating stale
      dependents.
      
      3. **Extract `update_dirty_state` helper on `TaskGuard`** — the "read
      old dirty state → apply new state → propagate via
      `ComputeDirtyAndCleanUpdate`" pattern was duplicated between
      `task_execution_canceled` and `task_execution_completed_finish`. The new
      `update_dirty_state` default method on `TaskGuard` handles both
      transitions (to `SessionDependent` or to `None`) and returns the
      aggregation job + `ComputeDirtyAndCleanUpdateResult` for callers that
      need post-processing (e.g. firing the `all_clean_event`).
      
      ### Why?
      
      These bugs caused observable failures when using Turbopack with
      filesystem caching (`--cache` / persistent cache):
      
      - `"Cell no longer exists"` panics/errors on incremental rebuilds after
      a task error.
      - Hangs on `stop_and_wait` during dev server shutdown.
      - Stale `"was canceled"` errors persisted in the cache breaking
      subsequent builds until the cache is cleared.
      
      ### How?
      
      Changes are in `turbopack/crates/turbo-tasks-backend/src/backend/`:
      
      **`mod.rs`:**
      - Guard the `cell_type_max_index` update block inside `if
      result.is_ok()` to skip it on error, with a cross-reference comment to
      `task_execution_completed_cleanup` (which similarly skips cell data
      removal on error — the two must stay in sync).
      - Move the `is_cancelled` bail in `try_read_task_cell` before the
      `listen_to_cell` call to avoid inserting phantom `InProgressCellState`
      events that would never be notified.
      - In `task_execution_canceled`: switch to `TaskDataCategory::All`
      (needed for dirty state metadata access), notify all pending in-progress
      cell events, and mark the task as `SessionDependent` dirty via the new
      helper.
      - In `task_execution_completed_finish`: replace ~77 lines of inline
      dirty state logic with a call to
      `task.update_dirty_state(new_dirtyness)`, preserving the
      `all_clean_event` post-processing and the `dirty_changed` variable under
      `#[cfg(feature = "verify_determinism")]`.
      
      **`operation/mod.rs`:**
      - Add `update_dirty_state` default method on `TaskGuard` trait (~60
      lines), co-located with the existing `dirty_state()` reader. Takes
      `Option<Dirtyness>`, applies the transition, builds
      `ComputeDirtyAndCleanUpdate`, and returns
      `(Option<AggregationUpdateJob>, ComputeDirtyAndCleanUpdateResult)`.
      - Add `ComputeDirtyAndCleanUpdateResult` to the public re-exports.
      
      ---------
      Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      be3ee02b
  2. 02 Apr, 2026 9 commits
    • nextjs-bot's avatar
      v16.2.1-canary.18 · cc79ef8c
      nextjs-bot authored
      cc79ef8c
    • Chris Tate's avatar
      Allow multi-level .localhost subdomains in dev origin check (#92262) · daca04d0
      Chris Tate authored
      ## Summary
      
      The built-in dev origin allowlist uses `*.localhost`, but `*` only
      matches a single subdomain level. Multi-level `.localhost` subdomains
      like `sub.app.localhost` are blocked even though all `.localhost`
      domains resolve to loopback per RFC 6761.
      
      This changes `*.localhost` to `**.localhost` so any depth of
      `.localhost` subdomain is auto-allowed. The `**` glob is already
      supported by `matchWildcardDomain` in `csrf-protection.ts`.
      
      - `**.localhost` matches `app.localhost` (single level, same as before)
      - `**.localhost` matches `sub.app.localhost` (multi-level, previously
      blocked)
      - Bare `localhost` is already separately in the allowlist, unaffected
      daca04d0
    • Hendrik Liebau's avatar
      Remove unnecessary ALS re-exports from `entry-base.ts` (#91527) · feae4cc4
      Hendrik Liebau authored
      The `workAsyncStorage`, `workUnitAsyncStorage`, and `actionAsyncStorage`
      instances were re-exported from `entry-base.ts` so that they could be
      accessed as properties of the bundled page module (`ComponentMod`). This
      indirection is no longer necessary because the `.external.ts` naming
      convention forces webpack to externalize these modules to `commonjs
      next/dist/...` (via `resolveNextExternal` in `handle-externals.ts`), and
      the `turbopack-transition: 'next-shared'` import attributes achieve the
      same for Turbopack. Both mechanisms guarantee that the bundled page
      module and direct imports resolve to the same singleton instance.
      
      This removes the three re-exports from `entry-base.ts` and replaces all
      `ComponentMod`-based access with direct imports from the `.external`
      modules in `static-paths/app.ts` and `action-handler.ts`.
      feae4cc4
    • Joseph's avatar
      docs: vt demo guide (#92249) · 2622a539
      Joseph authored
      2622a539
    • Zack Tanner's avatar
      fix: preserve HTTP access fallbacks during prerender recovery (#92231) · c06658e9
      Zack Tanner authored
      When a `notFound()`, `forbidden()`, or `unauthorized()` error escapes
      into the outer prerender recovery path, we were falling back to the
      generic error shell flow.
      
      In the `cacheComponents` case, that could leave us with:
      - error HTML rendered from `ErrorApp`
      - Flight data reused from the aborted prerender prelude
      - references to Flight chunks that were never emitted
      
      That is what caused the client-side `Connection closed` failure in
      #86251.
      
      Instead of rerendering the full Flight tree or always using the generic
      error RSC payload, this change:
      
      - finds the deepest matching HTTP fallback boundary
      - rerenders the normal app router payload with that segment-scoped
      fallback
      - tees the replacement Flight stream so Fizz can render from one copy
      while prerender buffering consumes the other
      - only takes this path for recoverable HTTP access fallbacks that have a
      real boundary (ie a defined not-found/unauthorized/etc)
      
      If no matching boundary exists, we keep the existing generic error
      handling.
      
      Fixes #86251
      Fixes #90837
      Closes #87041
      Closes #86251
      
      Closes NAR-711
      Closes NEXT-4876
      c06658e9
    • Tobias Koppers's avatar
      Fix pr-status.js: retry on API errors and report timed-out jobs (#92205) · e464ca39
      Tobias Koppers authored
      ### What?
      
      Fixes two bugs in `scripts/pr-status.js` that caused the script to
      silently report zero failures when there were actual CI failures.
      
      ### Why?
      
      When running `node scripts/pr-status.js 92080`, the script reported "No
      failed jobs found" despite the PR having real failures. Two root causes:
      
      1. **Transient API errors silently swallowed.** `getAllJobs()` had a
      bare `catch { break }` that returned an empty array on any GitHub API
      error (e.g., HTTP 502). Since the GitHub Actions jobs API for large runs
      frequently returns transient 502s, this caused false "no failures"
      reports.
      
      2. **`timed_out` and `startup_failure` jobs were invisible.** The script
      only checked for `conclusion === 'failure'`, but GitHub uses distinct
      conclusion values like `timed_out` (job exceeded timeout) and
      `startup_failure` (runner failed to start). These jobs fell through all
      filters and were silently omitted from reports.
      
      ### How?
      
      **Retry logic in `getAllJobs()`:**
      - Retries each paginated API call up to 3 times with 2s/4s backoff
      - If all retries fail on the first page, throws an error (no silent
      empty results)
      - If later pages fail after partial data is collected, warns and returns
      what was fetched
      
      **Broader failure detection with `FAILED_CONCLUSIONS`:**
      - Added a shared `FAILED_CONCLUSIONS` set: `{'failure', 'timed_out',
      'startup_failure'}`
      - Used in `getFailedJobs()`, `categorizeJobs()`, and flaky test
      detection
      - Jobs with non-`failure` conclusions are annotated in the report table
      (e.g., "(timed_out)")
      - `getFailedJobs()` now also returns the `conclusion` field so
      downstream code can distinguish failure types
      Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      e464ca39
    • Tim Neutkens's avatar
      Node.js streams: First pass (#90500) · 3421858b
      Tim Neutkens authored
      ### What?
      
      Note: This is only the first step. There's more follow-up PRs to
      implement the transforms as Node.js streams.
      
      Introduces a compile-time switchable Node.js streams layer for the app
      rendering pipeline, gated behind `__NEXT_USE_NODE_STREAMS`. When
      enabled, React's `renderToPipeableStream` / `resumeToPipeableStream`
      APIs produce native Node.js `Readable` streams instead of web
      `ReadableStream`s, eliminating repeated conversions between the two
      stream types during rendering.
      
      
      ### Why?
      
      The current rendering pipeline uses web `ReadableStream` everywhere to
      be consistent between Node.js/Edge, but the Node.js server ultimately
      pipes responses to Node `http.ServerResponse`. We found ReadableStream
      to be much slower than using Node.js streams directly, especially under
      load. By using Node.js streams natively throughout the pipeline, we can
      avoid this cost.
      
      ### How?
      
      - **`AnyStream` type** (`ReadableStream<Uint8Array> | Readable`):
      Introduced as the universal stream type across the rendering pipeline,
      replacing hardcoded `ReadableStream<Uint8Array>` in all stream-carrying
      signatures (`app-render.tsx`, `render-result.ts`,
      `flight-render-result.ts`, `hot-reloader-types.ts`, etc.).
      
      - **`stream-ops.ts` compile-time switcher**: Changed from a simple
      re-export of `stream-ops.web.ts` to a conditional `require()` that loads
      either `stream-ops.node.ts` or `stream-ops.web.ts` based on
      `process.env.__NEXT_USE_NODE_STREAMS`. Both modules export the same type
      surface so no casts are needed.
      
      - **`stream-ops.node.ts` (new)**: Node.js stream implementation that
      uses `renderToPipeableStream`, `resumeToPipeableStream`, and
      `PassThrough` for native pipeable rendering. Continue functions bridge
      to existing web transforms via `Readable.fromWeb()` / `Readable.toWeb()`
      at the boundary.
      
      - **`stream-ops.web.ts`**: Updated to wrap continue/utility functions
      instead of re-exporting them directly, so both modules have the same
      shaped exports. Added `teeStream`, `streamToUint8Array`,
      `processPrelude` wrappers.
      
      - **`debug-channel-server.ts` switcher**: Same compile-time pattern —
      loads `debug-channel-server.node.ts` (PassThrough-based) or
      `debug-channel-server.web.ts` (WritableStream-based).
      
      - **`pipe-readable.ts`**: Added `pipeNodeReadableToNodeResponse()` that
      pipes a Node `Readable` directly to `ServerResponse` with backpressure
      handling, without converting to web streams first.
      
      - **`render-result.ts`**: Accepts `Readable` as a response type. When a
      Node `Readable` is the response, `pipeToNodeResponse()` uses the new
      native pipe path. `readable` and `pipeable` getters convert via
      `Readable.toWeb()` only when needed.
      
      - **`app-render.tsx`**: Replaced `ReadableStream<Uint8Array>` with
      `AnyStream` throughout. Replaced `.tee()` calls with `teeStream()`.
      Updated `accumulateStreamChunks` to handle both stream types with a
      shared `accumulateChunk` helper. Removed `nodeStreamFromReadableStream`
      utility (no longer needed).
      
      - **`instant-validation.tsx`**: Changed from directly importing
      `renderToReadableStream` from `react-server-dom-webpack/server` to using
      the `renderToFlightStream` function from `stream-ops`, so validation
      uses the same stream backend as the main render.
      
      - **`use-flight-response.tsx`**: Updated debug stream handling to accept
      both `Readable` and `ReadableStream`, converting as needed.
      3421858b
    • JJ Kasper's avatar
      Add telemetry for adapterPath config usage (#92228) · 0aec1df2
      JJ Kasper authored
      <!-- CURSOR_AGENT_PR_BODY_BEGIN -->
      ## What?
      
      Adds telemetry tracking for when the `adapterPath` config option is used
      in Next.js.
      
      ## Why?
      
      As mentioned in the Slack discussion, telemetry for adapter usage was
      missing. This helps track adoption of the adapter feature.
      
      ## How?
      
      - Added `adapterPath` field to the `EventCliSessionStarted` type in
      `telemetry/events/version.ts`
      - The field is automatically populated from `nextConfig.adapterPath`
      when CLI sessions start
      - This covers both `next dev` and `next build` commands
      
      The telemetry emits a CLI session event with `"adapterPath": true` when
      the config option is set, and `"adapterPath": false` when it's not.
      
      ## Testing
      
      Updated the test in `test/integration/telemetry/test/config.test.ts` to:
      1. Create a config with `adapterPath` set
      2. Run a build with telemetry debug enabled
      3. Verify the CLI session telemetry includes `"adapterPath": true`
      
      The test passes locally.
      0aec1df2
    • Luke Sandberg's avatar
      remove the loop from StaticSortedFile::lookup (#91688) · e9597e6c
      Luke Sandberg authored
      ## Summary
      
      `StaticSortedFile::lookup` previously used a loop to traverse blocks, even though SST files always have exactly one index block (the last block). This unrolls the loop into a straight-line read of the index block followed by a direct dispatch to the key block, removing the loop overhead and the redundant empty-block `ensure!` checks that were subsumed by the length checks inside the key block functions.
      
      ## Benchmark results
      
      Read path (`static_sorted_file_lookup/entries_1000.00Ki`), canary vs this branch:
      
      | Benchmark | Canary | Branch | Change |
      |-----------|--------|--------|--------|
      | hit/uncached | 7.02 µs | 6.67 µs | **-5.0%** |
      | hit/cached | 141.0 ns | 134.2 ns | **-4.8%** |
      | miss/uncached | 5.16 µs | 5.08 µs | **-1.6%** |
      | miss/cached | 243.5 ns | 237.5 ns | **-2.5%** |
      
      A slight improvement is to be expected from simplifying control flow
      
      ## Test plan
      
      - [x] `cargo test -p turbo-persistence` — all tests passing
      - [x] Read path benchmarks verified improvement over canary
      e9597e6c
  3. 01 Apr, 2026 18 commits
    • nextjs-bot's avatar
      v16.2.1-canary.17 · 5b8dd585
      nextjs-bot authored
      5b8dd585
    • Joseph's avatar
      Docs/adapters review (#92223) · 0167a026
      Joseph authored
      Some corrections to the adapters docs.
      
      - The example deploy script ran `cat .next/BUILD_ID` before `pnpm
      build`. Under `set -euo pipefail` that kills the script immediately
      since the file doesn't exist yet. Moved the build step first.
      
      - `resolveRoutes` requires `URL` and `Headers` objects, not strings. The
      example would cause TypeScript/runtime errors.
      
      - Also documented the 6 return fields ~ other adapters might need to use
      all of them for redirects, external rewrites, and middleware
      short-circuiting.
      0167a026
    • Benjamin Woodruff's avatar
      Generate a CLI warning if using Rosetta 2 on Apple Silicon (#92220) · 93dc872d
      Benjamin Woodruff authored
      This PR is AI generated.
      
      Test plan (following https://github.com/vercel/next.js/pull/81950):
      
      - Build a preview deployment:
      https://github.com/vercel/next.js/actions/runs/23858712091/job/69559813673
      - Enable Rosetta
      - Download a standalone x64 macos binary from
      https://nodejs.org/en/download
      
      ```
      export PATH=/Users/bgw/Downloads/node-v22.17.1-darwin-x64/bin/:"$PATH"`
      pnpm dlx create-next-app@canary --yes intel-app
      cd intel-app
      nvim package.json # edit the next.js version to point to the preview deployment
      pnpm i
      pnpm dev
      ```
      
      <img width="723" height="192" alt="Screenshot 2026-04-01 at 9 25 04 AM"
      src="https://github.com/user-attachments/assets/a953ef8f-7fee-4aa0-9ef8-36ef667de734"
      />
      
      <img width="1022" height="278" alt="Screenshot 2026-04-01 at 9 26 35 AM"
      src="https://github.com/user-attachments/assets/a0d4b3bd-f8b7-4bbc-a7be-9113dabe189f"
      />
      
      (the bmi2 issue should be fixed by
      https://github.com/vercel/next.js/pull/92177, I just hadn't rebased)
      
      ---------
      Co-authored-by: 's avatarBenjamin Woodruff <bgw@users.noreply.github.com>
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      93dc872d
    • Luke Sandberg's avatar
      [turbopack] use a single query parameter for cache busting (#92214) · a6df8603
      Luke Sandberg authored
      No need to mention `next` here, and we can just add the random noise to the timestamp
      a6df8603
    • Tobias Koppers's avatar
    • Tobias Koppers's avatar
      feat: add NEXT_HASH_SALT env var for content-hash filename salting (#91871) · 3e015884
      Tobias Koppers authored
      ### What?
      
      Adds a `NEXT_HASH_SALT` environment variable **and** a
      `experimental.outputHashSalt` config option that mix a user-supplied
      string into every content-addressed hash used to generate chunk
      filenames and static asset filenames. This works for both Webpack and
      Turbopack.
      
      When both are set, the values are concatenated (`outputHashSalt +
      NEXT_HASH_SALT`), so a per-project salt can be baked into
      `next.config.js` while a per-deployment salt is injected at build time
      via the environment variable.
      
      ### Why?
      
      Content-addressed filenames (e.g. `chunk.abc123.js`) are derived from
      file content, so they only change when the content changes. There are
      deployment scenarios where you need to force all filenames to rotate —
      for example after a CDN misconfiguration has poisoned caches for a
      particular hash space — without actually changing source code. A stable,
      opt-in salt lets operators do this without touching application code.
      
      Some customers prefer the config-file approach
      (`turbopack.outputHashSalt`) over environment variables, so both are
      supported.
      
      ### How?
      
      **Webpack** already has `output.hashSalt` in its config. We simply
      forward `NEXT_HASH_SALT` to that option.
      
      **Turbopack** required threading the value through several layers:
      
      1. The effective hash salt is computed once in
      `assignDefaultsAndValidate` as `config.turbopackHashSalt =
      (turbopack.outputHashSalt ?? '') + (NEXT_HASH_SALT ?? '')` and stored on
      `NextConfigComplete`. Both `turbopackBuild` (production) and
      `createHotReloaderTurbopack` (dev) read from this single field.
      2. `ProjectOptions.hash_salt` receives the pre-computed salt.
      3. `Project` stores the salt and passes it into the three chunking
      context option structs (`ClientChunkingContextOptions`,
      `ServerChunkingContextOptions`, `EdgeChunkingContextOptions`).
      4. Both `BrowserChunkingContext` and `NodeJsChunkingContext` gain a
      `hash_salt: RcStr` field.
      5. A new `deterministic_hash_with_salt(salt, input, algorithm)` function
      in `turbo-tasks-hash` writes the salt bytes first, then the content
      bytes, into a single hasher — one pass, no hash-of-hash composition.
      6. A matching `content_hash_with_salt` method is added to `FileContent`
      and `AssetContent`.
      7. `ChunkingContext::asset_path` is changed to accept `Vc<AssetContent>`
      (instead of a pre-computed `Vc<RcStr>`) so the chunking context can
      choose the correct hash path itself. `StaticOutputAsset::path`
      simplifies accordingly.
      
      Without `NEXT_HASH_SALT` and without `turbopack.outputHashSalt` set,
      behaviour is identical to before — no hash change, no performance
      impact.
      
      **e2e test** (`test/production/app-dir/hash-salt/`) verifies:
      - Two builds with the same salt produce identical chunk and static asset
      filenames.
      - A build with a different salt produces different filenames.
      - `turbopack.outputHashSalt` (config) changes filenames vs no salt.
      - Combined config + env salt differs from either alone.
      - Runs for both Turbopack and Webpack.
      
      ---------
      Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      Co-authored-by: 's avatarLuke Sandberg <lukesandberg@users.noreply.github.com>
      3e015884
    • Niklas Mischkulnig's avatar
      Turbopack: trace fs.readdir calls (#92148) · a5c0a897
      Niklas Mischkulnig authored
      Handle fs.readdir calls for NFT
      a5c0a897
    • Tim Neutkens's avatar
      Reapply "ci: add node-stream test coverage workflow (#89861)" (#91664) · 4582b5fa
      Tim Neutkens authored
      Re-apply #89861.
      
      Somehow the tests passed in the PR but failed after merging. Will dig
      into it.
      
      Edit: Dug into it, there was a missing env var. Fixed and ready to merge
      now.
      
      PR doesn't add the Node.js streams code path. Implementation starts in
      #90500
      4582b5fa
    • Sebastian "Sebbie" Silbermann's avatar
    • JJ Kasper's avatar
      docs: clarify id, filePath, and pathname in STATIC_FILE adapter output (#92227) · cc710321
      JJ Kasper authored
      ## What
      
      Adds documentation for the `id`, `filePath`, and `pathname` properties
      in the `STATIC_FILE` adapter output type.
      
      ## Why
      
      These three string properties were previously undocumented or had
      ambiguous descriptions. Based on feedback from the team:
      - `id` is a unique identifier for the static file output
      - `filePath` is the absolute filesystem path to the built file
      - `pathname` is the routable URL pathname
      
      ## Changes
      
      - Added JSDoc comments to the `STATIC_FILE` type definition in
      `build-complete.ts`
      - Updated the MDX documentation in `output-types.mdx` with clearer
      inline comments
      cc710321
    • Vercel Release Bot's avatar
      Update Rspack production test manifest (#92143) · 01f7cd13
      Vercel Release Bot authored
      This auto-generated PR updates the production integration test manifest used when testing Rspack.
      01f7cd13
    • Zack Tanner's avatar
      partial fallbacks: adapter support for intermediate shells (#91902) · c2914790
      Zack Tanner authored
      Previously, `partialFallback` was only emitted when all dynamic params
      could become fully concrete after upgrade. For a route like
      `/prefix/[one]/[two]` where only `[one]` has generateStaticParams, the
      feature was disabled entirely.
      
      This relaxes the guard to allow adapters to produce an intermediate
      shell for not fully known params, and tweaks the handling to support
      when both known and unknown params are provided to the render.
      Concretely:
      
      - When partial `nxtP*` params are provided during background
      revalidation but `normalizeDynamicRouteParams `rejects them (missing
      params), merge the provided params into the existing params to override
      placeholders.
      - Compute `effectiveFallbackRouteParams` by filtering to only params
      that still have placeholder values. Use this filtered set for
      `fallbackRouteParams` so intermediate shells render resolved params in
      the static shell and only suspend for truly unknown params
      c2914790
    • Joseph's avatar
      docs: local images referenced by remote source (#92178) · faa4b992
      Joseph authored
      It was discovered that one could let a remote source, safely-ish, load
      local images, which has the benefit of providing, width, height, src,
      and blur-* props which we could pass to next/image.
      
      Closes:
      https://linear.app/vercel/issue/DOC-6288/local-images-referenced-by-a-remote-source
      faa4b992
    • Jude Gao's avatar
      Add internal header security guideline to AGENTS.md (#92128) · 8b5dfa66
      Jude Gao authored
      ## Summary
      
      Adds a security guideline to `AGENTS.md` that instructs the PR reviewer
      to flag new code that reads non-standard request headers without
      checking them against the `INTERNAL_HEADERS` filter list in
      `packages/next/src/server/lib/server-ipc/utils.ts`.
      
      ## Context
      
      `filterInternalHeaders()` strips internal headers from incoming requests
      at the router-server entry point. When new internal headers are
      introduced but not added to the filter list, external attackers can
      forge them. This guideline helps catch those gaps during code review.
      
      Validated in #92122 — the reviewer successfully flagged a test violation
      using this guideline.
      
      ## Test plan
      
      - [x] Verified the reviewer catches unfiltered header reads with this
      guideline (see #92122)
      8b5dfa66
    • Sebastian "Sebbie" Silbermann's avatar
    • Sebastian "Sebbie" Silbermann's avatar
    • dagecko's avatar
      fix: pin 19 actions to commit SHA, extract 7 expressions to env vars (#92016) · f7de136c
      dagecko authored
      Re-submission of #91933. Had a problem with my fork and had to delete
      it, which closed the original PR. Apologies for the noise.
      
      ## Summary
      
      This PR pins all GitHub Actions to immutable commit SHAs instead of
      mutable version tags and extracts expressions from `run:` blocks into
      `env:` mappings.
      
      - Pin 19 unpinned actions across workflow files to full 40-character
      SHAs
      - Add version comments for readability (e.g., `@abc123 # v1.0.9`)
      - Extract 2 secrets and 5 workflow_dispatch inputs from run blocks to
      env vars
      
      ## Changes by file
      
      | File | Changes |
      |------|---------|
      | build_and_deploy.yml | Pinned ijjk/rust-cache, ast-grep/action,
      taiki-e/install-action to SHA |
      | build_reusable.yml | Pinned ijjk/rust-cache,
      SimenB/github-actions-cpu-cores to SHA |
      | cancel.yml | Pinned withgraphite/graphite-ci-action to SHA, extracted
      GRAPHITE_TOKEN to env var |
      | lock.yml | Pinned dessant/lock-threads to SHA |
      | notify_slack.yml | Pinned slackapi/slack-github-action to SHA (2
      instances) |
      | publish_canary.yml | Extracted NPM_TOKEN_ELEVATED to env var |
      | publish_release.yml | Extracted 5 workflow_dispatch inputs to env vars
      |
      | retry_deploy_test.yml | Pinned dtolnay/rust-toolchain to SHA |
      | triage.yml | Pinned balazsorban44/nissuer to SHA |
      | turbopack_benchmark.yml | Pinned taiki-e/install-action,
      ijjk/rust-cache, CodSpeedHQ/action to SHA |
      | turbopack_benchmark_wasm.yml | Pinned taiki-e/install-action,
      CodSpeedHQ/action to SHA |
      | turbopack_benchmark_xtask.yml | Pinned taiki-e/install-action,
      CodSpeedHQ/action to SHA |
      
      ## Actions Pinned
      
      | Action | Version | SHA |
      |--------|---------|-----|
      | ijjk/rust-cache | turbo-cache-v1.0.9 | a34594c45081... |
      | ast-grep/action | v1.5.0 | cf62e780f0c8... |
      | taiki-e/install-action | nextest / v2 | 3a0adb... / 7627fb... |
      | withgraphite/graphite-ci-action | main | ee395f3a7825... |
      | dessant/lock-threads | v5 | 1bf7ec25051f... |
      | slackapi/slack-github-action | v1.25.0 | 6c661ce58804... |
      | SimenB/github-actions-cpu-cores | v2 | 97ba232459a8... |
      | dtolnay/rust-toolchain | stable | 631a55b12751... |
      | balazsorban44/nissuer | 1.10.0 | 92ef22afd6a7... |
      | CodSpeedHQ/action | v4 | 1c8ae4843586... |
      
      ## A note on internal action pinning
      
      This PR pins all actions including org-owned ones. Best practice is to
      pin everything \u2014 the tj-actions/changed-files attack was an
      internally maintained action that was compromised, and every repo
      referencing it by tag silently executed attacker code. That said, it's
      your codebase. If you'd prefer to leave org-owned actions unpinned, let
      us know and we'll adjust the PR.
      
      ## How to verify
      
      Review the diff \u2014 each change is mechanical and preserves workflow
      behavior:
      - **SHA pinning**: `action@v3` becomes `action@abc123 # v3` \u2014
      original version preserved as comment
      - **Expression extraction**: `${{ expr }}` in `run:` moves to `env:`
      block, referenced as `$ENV_VAR` in the script
      - No workflow logic, triggers, or permissions are modified
      
      I put up some research on this on
      [Twitter](https://x.com/vigilance_one/status/2036581210663616729) and a
      [research
      site](https://www.vigilantdefense.com/research/github-top-50k-repos-cicd-security-scan)
      if you want more context. I wrote a scanner called Runner Guard and open
      sourced it [here](https://github.com/Vigilant-LLC/runner-guard).
      
      If you have any questions, reach out. I'll be monitoring comms.
      
      \\- Chris Nyhuis (dagecko)
      
      ---------
      Co-authored-by: 's avatarBenjamin Woodruff <github@benjam.info>
      Co-authored-by: 's avatarBenjamin Woodruff <benjamin.woodruff@vercel.com>
      f7de136c
    • Aurora Scharff's avatar
      Improve revalidateTag JSDoc to include guidance about required second parameter (#92176) · 36fcc163
      Aurora Scharff authored
      ### What?
      
      Improved the JSDoc comment on `revalidateTag` to explain the required
      second `profile` parameter, linking to `cacheLife` profile docs and
      mentioning `updateTag` as an alternative for immediate expiration.
      
      ### Why?
      
      The TypeScript error "Expected 2 arguments, but got 1" at
      `revalidateTag` call sites gives no actionable guidance. When users
      hover over the function in their IDE, the existing JSDoc only says
      "purge cached data on-demand" — nothing about what the second argument
      should be or what alternatives exist.
      
      ### How?
      
      Added a prose paragraph to the JSDoc describing the `profile` parameter
      (a `cacheLife` profile like `"max"` or a `{ expire }` object) and
      pointing users to `updateTag` for immediate expiration in Server
      Actions. Follows the established JSDoc conventions in the file (no
      `@param`, `@example`, or `@see` tags).
      
      ## PR checklist (Fixing a bug)
      
      - Errors have a helpful link attached: links to `cacheLife` reference,
      `updateTag` docs, and `revalidateTag` docs
      36fcc163
  4. 31 Mar, 2026 2 commits
    • Luke Sandberg's avatar
      disable bmi2 in qfilter (#92177) · 5ef10c67
      Luke Sandberg authored
      Fixes #91708 
      
      set the legacy_x86_64_support feature on qfilter to support older intel cpus
      5ef10c67
    • Luke Sandberg's avatar
      simplify session dependent tasks and add TTL support (#91729) · fe99f0d6
      Luke Sandberg authored
      ## Summary
      
      Three related improvements to turbo-tasks session-dependent task handling:
      
      ### 1. Make `session_dependent` a function attribute
      
      Previously, tasks called `mark_session_dependent()` at runtime to flag themselves. This PR makes it a compile-time `#[turbo_tasks::function(session_dependent)]` attribute instead. Benefits:
      
      - **Enables eager aggregation number selection**: Session-dependent tasks change on every session restore, behaving like dirty leaf nodes. By knowing at task creation time (not mid-execution) that a task is session-dependent, the backend can assign a high initial aggregation number, preventing long dirty-propagation chains through intermediate aggregated nodes.
      - **Simpler API**: No runtime `mark_session_dependent()` call needed — the attribute is declarative and statically checked.
      - Removes `mark_session_dependent()`, `mark_own_task_as_session_dependent()`, and the `session_dependent` field from `InProgressStateInner`. The backend now reads `is_session_dependent` directly from the `NativeFunction` metadata via `TaskGuard::is_session_dependent()`.
      
      ### 2. Fix fetch to respect HTTP `Cache-Control` headers
      
      Previously, `fetch` results were cached indefinitely meaning results would never be refreshed (unless the cache was invalidated).  Now they are `session_dependent` with a TTL to ensure we respect the http settings (e.g. Google Fonts with `max-age=86400`).
      
      New two-task pattern:
      - **`fetch_inner`** ( NOT `session_dependent`): Performs the HTTP request, grabs an `Invalidator` for itself, and returns the response + invalidator + absolute deadline. Cached across sessions.
      - **`fetch`** (`network`, `session_dependent`): Reads the cached `fetch_inner` result and spawns a timer to invalidate when the TTL expires.
      
      On warm cache restore, `fetch` re-executes (session-dependent), reads the persisted deadline from `fetch_inner`'s cached result, computes remaining TTL, and spawns a timer — no HTTP request unless the TTL has already expired. Mid-session, the timer fires and triggers a re-fetch.
      
      Error handling: On fetch failure, `fetch_inner` takes a dependency on `Completion::session_dependent()` so transient errors (network down, DNS failure) are retried on the next session without busy-looping.
      
      ### 3. Drop `TransientState` in favor of inline solution
      
      `TransientState` was only used in one place (`EcmascriptModuleAsset::last_successful_parse`) and brought unnecessary complexity — it registered invalidators and called `mark_session_dependent()` on every read. Replaced with a simple `TransientCache<T>` local to `turbopack-ecmascript` that is just a `Mutex<Option<T>>` with `#[bincode(skip)]`. 
      
      ## Test Plan
      
      - 3 new integration tests in `turbo-tasks-fetch/tests/fetch.rs`:
        - `ttl_invalidates_within_session` — mock server returns `max-age=1`, body changes, verifies re-fetch after TTL
        - `ttl_invalidates_on_session_restore` — fetches with TTL, stops TT, waits for expiry, warm restores with new TT, verifies re-fetch
        - `errors_retried_on_session_restore` — server returns 500, stops TT, fixes server, warm restores, verifies success
      - Existing 6 fetch tests continue to pass
      - `cargo check -p turbo-tasks -p turbo-tasks-backend -p turbo-tasks-fetch`
      fe99f0d6