1. 17 Jan, 2026 4 commits
  2. 16 Jan, 2026 24 commits
    • Luke Sandberg's avatar
      [turbopack] Add bundling support for worker_threads (#87746) · 09296125
      Luke Sandberg authored
      Add support for bundling worker_threads workers
      
      Previously we only supported tracing dependencies of worker threads.  However, this could trigger issues if the callsite was getting bundled since we would believe that the file was both bundled and unbundled.
      
      The solution is to support bundling modules using worker threads and implementing the threads.  This requires a new reference and loader module type which follows the patter of async-loaders and webworkers. 
      
      An interesting consideration is about file extensions.  `new Worker(...)` takes a relative or absolute filepath, in node 23+ that means you can load typescript files directly, so we support the same.  If you want to load a `.ts` file you need to write `foo.ts` we don't do any pattern rewriting.
      
      This fixes a bug reported by an X user: https://x.com/strugglercss/status/2002504736860484008?s=20.  The problem with the previous approach is that we would record the reference as 'traced', but if you did `new Worker(__filename,...)` then we would end up with 'traced references' to a file that was bundled.  This caused issues during tracing when we tried to add CachedExternalModule references to the nft json files
      
      ```
      Error [TurbopackInternalError]: NftJsonAsset: cannot handle filepath url
      
      Debug info:
      - Execution of get_all_written_entrypoints_with_issues_operation failed
      - Execution of EntrypointsOperation::new failed
      - Execution of all_entrypoints_write_to_disk_operation failed
      - Execution of Project::emit_all_output_assets failed
      - Execution of emit_assets failed
      - Execution of emit failed
      - Execution of <NftJsonAsset as Asset>::content failed
      - NftJsonAsset: cannot handle filepath url
          at <unknown> (TurbopackInternalError: NftJsonAsset: cannot handle filepath url) {
      ```
      
      there `url` was due to a `require('url')` statement in a bundled file this caused us to produce an external shim, but a `new Worker(__filename)` caused us to also create a traced reference to the same file.  The problem there was simply that the `ident()` for a `CachedExternalModule` contains a dummy filepath that broke the nft.json asset production.   The root issue here is that the `FilePathModuleReference` was using the wrong `AssetContext` to construct the referenced module which lead to the wrong files being traced.   After investigation @mischnic and I determined that that was an insufficient fix since we really do need to rewrite the reference.   Proper bundling support fixes this directly and the pattern here paves the way for more worker support in the future.
      
      This doesn't seem like the only way a synthetic module (like an extern module) might end up as a dependency of traced module, so a more robust solution is probably in order.
      09296125
    • nextjs-bot's avatar
      v16.1.1-canary.31 · 05406f6e
      nextjs-bot authored
      05406f6e
    • Benjamin Woodruff's avatar
    • jgeschwendt's avatar
      fix: capture promisified setImmediate separately (#88346) · 5a12867c
      jgeschwendt authored
      ### What?
      
      Capture `setImmediate[promisify.custom]` at module initialization
      instead of lazily accessing it when needed.
      
      ```
          RangeError: Maximum call stack size exceeded
      
            at patchedSetImmediatePromise (node_modules/.pnpm/next@16.1.1_@babel+core@7.28.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/src/server/node-environment-extensions/fast-set-immediate.external.ts:626:27)
            at originalPromisify (node_modules/.pnpm/next@16.1.1_@babel+core@7.28.5_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/src/server/node-environment-extensions/fast-set-immediate.external.ts:627:12)
      ```
      
        This was discovered upgrading from `16.0.10` to `16.1.0`
      
        ### Why?
      
      When `util.promisify(setImmediate)` is called and `currentExecution ===
      null`, the code was accessing `originalSetImmediate[promisify.custom]`
      at call time. However, `promisify.custom` can get lost or return
      `undefined` after the module patches `setImmediate`, causing
      `promisify(setImmediate)` to fail. Specifically, when used with `jest`.
      
      Reproduction:
      https://github.com/jgeschwendt/nextjs-setimmediate-promisify-repro
      - Failing:
      https://github.com/jgeschwendt/nextjs-setimmediate-promisify-repro/actions/runs/20864170776
      - Passing (with fix):
      https://github.com/jgeschwendt/nextjs-setimmediate-promisify-repro/actions/runs/20864380068
      -
      https://github.com/jgeschwendt/nextjs-setimmediate-promisify-repro/pull/1
      
        ### How?
      
      Move the capture of `originalSetImmediate[promisify.custom]` to module
      initialization time (alongside `originalSetImmediate`,
      `originalClearImmediate`, and `originalNextTick`), ensuring the original
      promisified implementation is preserved before any patching occurs.
      5a12867c
    • Will Binns-Smith's avatar
      Turbopack: use bugs.nextjs.org for Turbopack panic error reports (#88356) · d3b3e3a3
      Will Binns-Smith authored
      Update the bug report link to use the new bugs.nextjs.org service
      instead of the direct GitHub discussions URL. Also shares more code when
      handling terminals that don't support links.
      
      Test Plan: Added a deliberate panic to a turbotask, verified the link.
      d3b3e3a3
    • Tobias Koppers's avatar
      Turbopack: add support for matching loaders on resource queries (#88644) · 7e9d7cbd
      Tobias Koppers authored
      ### What?
      
      Part of  PACK-1007
      
      Adds `condition.query` support to Turbopack's loader rules, enabling loaders to match based on import query strings (e.g., `import './file?raw'`). This mirrors webpack's `resourceQuery` functionality.
      
      The `query` condition accepts either a string (exact match) or RegExp (pattern match).
      
      Adds tests and documentation for the new `condition.query` option.
      
      ### How to use
      
      ```js
      // next.config.js
      module.exports = {
        turbopack: {
          rules: {
            '*.txt': [
              // String: exact match
              { condition: { query: '?raw' }, loaders: ['raw-loader'], as: '*.js' },
              // RegExp: pattern match  
              { condition: { query: /\?transform/ }, loaders: ['transform-loader'], as: '*.js' },
            ],
          },
        },
      }
      ```
      7e9d7cbd
    • Neha Prasad's avatar
      fix: make RedirectType constant properties literal types (#88653) · 5ad737c9
      Neha Prasad authored
      ### What?
      
      Fixed TypeScript error where `RedirectType.replace` and
      `RedirectType.push` were typed as `string` instead of literal types,
      causing compilation errors when used with `redirect()`.
      
      ### Why?
      
      `RedirectType` constant properties weren't properly typed as literal
      types, causing TypeScript to see them as generic `string` values instead
      of the expected `'push' | 'replace'` union.
      
      ### How?
      
      - Added `as const` to `RedirectType` properties in
      `packages/next/src/client/components/navigation.react-server.ts`.
      
      Fixes #88627
      
      ---------
      Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
      5ad737c9
    • nextjs-bot's avatar
    • nextjs-bot's avatar
      v16.1.1-canary.30 · f67bc23b
      nextjs-bot authored
      f67bc23b
    • Tobias Koppers's avatar
      Turbopack: add caching to chunking (#88561) · c38e57fd
      Tobias Koppers authored
      ### What?
      
      Make make_chunks a cached function to allow it to be cached even when the module graph changes (assuming that chunk group's chunk items are not affected by the change)
      c38e57fd
    • Tobias Koppers's avatar
      Turbopack: use selective reads for merged modules (#88560) · a8b0f9db
      Tobias Koppers authored
      ### What?
      
      Use selective reads for merged modules data.
      
      This is a preparation to make chunking be less dependent on module graph changes.
      a8b0f9db
    • Tobias Koppers's avatar
      Turbopack: selective read for module_chunk_groups in ChunkGroupInfo (#88559) · bbf8aec9
      Tobias Koppers authored
      ### What?
      
      Use selective reads for module chunk groups from chunk group info
      
      This is a preparation to make chunking be less dependent on module graph changes.
      bbf8aec9
    • Jiachi Liu's avatar
      8cfdcacf
    • Jiachi Liu's avatar
      feat: server action logging (#88277) · 3aad67b7
      Jiachi Liu authored
      3aad67b7
    • Tobias Koppers's avatar
      Turbopack: MappedReadRef should be Send and Sync (#88558) · 43460b17
      Tobias Koppers authored
      ### What?
      
      To be able to used MappedReadRefs in async context, they need to be Send.
      43460b17
    • Tobias Koppers's avatar
      Turbopack: avoid chunk_item_id task and use selective cell access instead (#88411) · 8d5b9374
      Tobias Koppers authored
      ### What?
      
      Use selection reads for module id to avoid functions
      8d5b9374
    • Tobias Koppers's avatar
      Turbopack: follow tracing spans through aggregation update queue (#88410) · dd39efc7
      Tobias Koppers authored
      ### What?
      
      follow spans through the aggregation update queue
      dd39efc7
    • Tobias Koppers's avatar
      Turbopack: Consistency for compute_async_module_info (#88409) · 22fb1a01
      Tobias Koppers authored
      ### What?
      
      Use strongly consistent reads for compute_async_module_info to avoid double execution.
      22fb1a01
    • Tobias Koppers's avatar
      Turbopack: snapshot the ModuleGraph to avoid (eventual) inconsistent graphs (#88340) · cfe29f98
      Tobias Koppers authored
      ### What?
      
      Refactor ModuleGraph to be a strongly consistent snapshot of the module graph. This should avoid eventually consistency problems where different versions of single module graphs do not fit together.
      cfe29f98
    • Tobias Koppers's avatar
      Turbopack: unflake unit test (#88620) · 8ae72f2a
      Tobias Koppers authored
      ### What?
      
      Too few tasks leave no space for tokio to act.
      8ae72f2a
    • Jiachi Liu's avatar
      doc: add details of mcp client integration (#88543) · 9fccecc3
      Jiachi Liu authored
      add link to the mcp client configuration details section before the code
      block of example
      
      ---------
      Co-authored-by: 's avatarVercel <vercel[bot]@users.noreply.github.com>
      Co-authored-by: 's avatartimneutkens <tim@timneutkens.nl>
      9fccecc3
    • Tim Neutkens's avatar
      Fix incorrect 'Ready in' time for next start (#88589) · 166e0ef3
      Tim Neutkens authored
      ## What
      
      Fix the incorrect "Ready in" time displayed when running `next start`.
      The bug caused the time to show impossibly large values like "Ready in
      29474457.7min" instead of the actual startup duration.
      
      ## Why
      
      The `NEXT_PRIVATE_START_TIME` environment variable was not being
      properly set/propagated when `startServer()` read it. When the variable
      was missing, the code defaulted to `0`, causing the calculation
      `Date.now() - 0` to equal the entire Unix timestamp (~1.77 trillion
      milliseconds ≈ 29 million minutes).
      
      ## How
      
      1. Added a fallback in `cli/next-start.ts` to set
      `NEXT_PRIVATE_START_TIME` if it's not already set by `bin/next.ts`
      2. Updated the calculation in `start-server.ts` to use `0` as the
      duration if `startTime` is falsy, preventing the bug
      3. Removed unused performance mark code that was leftover
      
      ## Test Plan
      
      Run `next start` on a production build and verify the "Ready in" time
      shows a reasonable value (e.g., "Ready in 523ms" instead of millions of
      minutes).
      166e0ef3
    • Sebastian "Sebbie" Silbermann's avatar
      [ci] Use native `concurrency` feature in build-and-test (#87287) · 52b2b8be
      Sebastian "Sebbie" Silbermann authored
      Last remaining workflow using our custom cancel workflow.
      
      Using the same concurrency logic as build-and-deploy
      52b2b8be
    • Tobias Koppers's avatar
      Turbopack: avoid removing cells for erroring tasks (#88305) · fcfcbce3
      Tobias Koppers authored
      ### What?
      
      * avoid flagging tasks dirty when removing cells
      * For errored tasks: avoid removing cell content
      * For ok tasks: remove cell content later to collect more stale signals
      fcfcbce3
  3. 15 Jan, 2026 11 commits
    • nextjs-bot's avatar
      v16.1.1-canary.29 · e5905bde
      nextjs-bot authored
      e5905bde
    • Janka Uryga's avatar
      [CC] Fix dev validation error from server action bound args (#88600) · bd90b6c5
      Janka Uryga authored
      In Cache Components, bound args encryption needs to be cached (and
      tracked with cacheSignal) because it's tasky. We use the serialized
      bound args themselves as a cache key. However, in dev, the key ends up
      containing debug info (in particular, timing information) so it's
      different every time . This causes a cache miss and results in a static
      shell validation failure.
      
      The fix is to use a dummy debug channel to pipe the problematic debug
      info into the void and thus make the key be deterministic.
      bd90b6c5
    • Steven's avatar
      fetch(next/image): reduce maximumResponseBody from 300MB to 50MB (#88588) · 54476c9c
      Steven authored
      Based on our metrics, the P99.9 for a source image is 47 MB so we can
      adjust the default setting to be much lower (by changing from from 300
      MB to 50 MB) in favor of reducing memory.
      54476c9c
    • Tobias Koppers's avatar
      Turbopack: run tasks with priority based on distance to leaf (#87662) · 125b7d89
      Tobias Koppers authored
      ### What?
      
      * Compute the approximate distance to leaf in the dependency graph
      * Prioritize tasks re-computing by distance to leaf, running leaf tasks first
      
      This ensures that it's less likely that tasks are re-executed multiple times due to bad ordering.
      This adresses the "diamond" problem where a task is invalidated multiple times due to multiple paths of invalidation to that task.
      125b7d89
    • Niklas Mischkulnig's avatar
      Turbopack: support disabling tsconfig lookup (#88529) · 3933d47b
      Niklas Mischkulnig authored
      Introduce `TsConfigHandling::Disabled`
      3933d47b
    • Matt Mastracci's avatar
    • Niklas Mischkulnig's avatar
      Update labeler.json (#88591) · 5ec2d236
      Niklas Mischkulnig authored
      5ec2d236
    • Donny/강동윤's avatar
    • Hendrik Liebau's avatar
      [ci] Don't retry/notify for failed deploy tests with custom tarball URLs (#88576) · f5c8b6ae
      Hendrik Liebau authored
      Fixes a regression from #85981 where manual deploy tests with custom
      tarball URLs incorrectly trigger retries and Slack notifications. Now
      only release-triggered runs and manually-triggered canary tests are
      retried/reported.
      f5c8b6ae
    • Tim Neutkens's avatar
      docs: fix Pages Router fonts documentation showing App Router examples (#88326) · 8d7682f1
      Tim Neutkens authored
      ## Summary
      
      Fixes #88291
      
      The Pages Router fonts documentation was incorrectly showing App Router
      examples (`app/layout.tsx`) which don't exist in Pages Router. This
      confused users trying to use fonts with the Pages Router.
      
      ## Changes
      
      Updated `docs/01-app/01-getting-started/13-fonts.mdx` to include proper
      `<AppOnly>` and `<PagesOnly>` sections:
      
      **For Pages Router users:**
      - Added examples using `pages/_app.tsx` (Custom App) to wrap components
      with font className
      - Added examples using `pages/_document.tsx` (Custom Document) to apply
      fonts to the `<html>` element
      
      **For App Router users:**
      - Wrapped existing `app/layout.tsx` examples in `<AppOnly>` sections
      
      This follows the same pattern used in other shared documentation like
      `docs/01-app/01-getting-started/11-css.mdx` which properly separates App
      Router and Pages Router content.
      8d7682f1
    • Luke Sandberg's avatar
      feat: add TaskStorage derive macro and schema infrastructure (#88338) · 02f8ba61
      Luke Sandberg authored
      Add a new derive macro for `TaskStorage` a replacement for `InnerStorage` and `CachedDataItem`, currently it is unused outside of tests.
      
      ## What
      
      * add a new derive macro that generates code from the 'schema' in `storage_schema.rs`
      * `storage_schema.rs` defines the layout of our new struct, for each field we specify
         * type and name
         * category ('data' 'meta' or 'transient')
         * location (inline or lazy or flags for bitfields)
         * whether we should `filter_transient` when encoding (not everything can contain transient data)
         * Logically this is a replacement for `CachedDataItem`
      * From that we generate a few things
         * `TaskFlags` a bitfield to hold some data items as well as 'meta' information like the 'snapshot' and 'restore' bits replacing `InnerStorageState`
         * `LazyField`  enum, defines tall the fields that we dynamically allocate
         * `TaskStorage` the main storage struct, along with basic accessors for all the datatypes (which helps encapsualte storage strategy)
         * `TaskStorageAccessors` a trait with default implementations of every accessor which also handle
            * access checking, via `check_access`
            * mutation tracking via `track_mutation`
             * putting these behaviors in a trait allows some of the business logic around snapshotting to remain in normal rust code that implements the trait, while all the field updating logic can be autogenerated
      
        * Serialization and encoding infrastructure
            * routines to encode and decode the 'meta' or 'data' subsets
            * routines to create partial 'snapshots' of `meta` or `data` subsets
            * routines to restore data from deserialized snapshots
      
      See https://gist.github.com/lukesandberg/ea35f0e92c1cdeddf80d0498f2978144 for a fully expanded version of the macro
      
      ### Why
      
      There are a few goals from this redesign of `InnerStorage`
      
      * (speculative) a single large `derive` macro will be easier to maintain than the current mix of `macro_rules` and derive macros we use for `CacheDataItem`
          * There is one macro to expand when inspecting and the macro generation code is pretty straightforward if voluminous
      * We eliminate many `match` operations on `CachedDataItem`
          * Today to lookup a piece of data we need to execute several matches to get the the data category and find the storage location.  With this new approach those are handled by just calling the correct accessor which statically addresses the storage location
      * serialization performance
          * we don't need to 'explode' the storage into `Vec<CachedDataItem>` anymore and instead can either directly snapshot the storage or encode directly to a buffer.  This should eliminate some temporary allocations and should enable a smaller serialization format
      * more flexibility
          * mostly this is the same approach as before with a few small improvements, notably `invalidator` and `immutable` are now stored as single inline bits reducing lookupcosts and memory for tasks that have these.
      
      ### How
      
      Most of the code was written by Claude with obviously a ton of feedback, so please review carefully.  For now all this code is unused but future PRs will integrate it into the backend
      02f8ba61
  4. 14 Jan, 2026 1 commit