1. 01 Aug, 2025 6 commits
  2. 31 Jul, 2025 16 commits
    • nextjs-bot's avatar
      v15.4.2-canary.25 · f6431004
      nextjs-bot authored
      f6431004
    • Andrew Clark's avatar
      Parse dynamic params on the client (#82185) · e8b99e14
      Andrew Clark authored
      This is part of a larger effort to remove dynamic params from server
      responses except in cases where they are needed to render a Server
      Component. If a param is not rendered by a Server Component, then it can
      be omitted from the cache key, and cached responses can be reused across
      pages with different param values.
      
      In this step, I've implemented client parsing of the params from the
      response headers.
      
      The basic approach is to split the URL into parts, then traverse the
      route tree to pick off the param values, taking care to skip over things
      like interception routes.
      
      Notably, this is not how the server parses param values. The server gets
      the params from the regex that's also used for routing. Originally, I
      thought I'd send the regex to the client and use it there, too. However,
      this ended up being needlessly complicated, because the server regexes
      are also used for things like interception route matching. But this is
      already encapsulated by the structure of the route tree. So it's easier
      to just walk the tree and pick off the params.
      
      My main hesitation is that this introduces some risk of drift between
      the server and client params parsing; we'll need to keep them in sync.
      However, I think the solution is actually to update the server to also
      pick the params off the URL, rather than use the ones passed from the
      base router. It's conceptually cleaner, since it's less likely that
      extra concerns from the base server leaking into the application layer.
      As an example, compare the code needed to get a catchall param value in
      the
      [client](https://github.com/acdlite/next.js/blob/09b16a816ff4d595b5111cb1a6de540838caf97e/packages/next/src/client/client-params.ts#L57-L61)
      versus the
      [server](https://github.com/acdlite/next.js/blob/09b16a816ff4d595b5111cb1a6de540838caf97e/packages/next/src/shared/lib/router/utils/get-dynamic-param.ts#L37-L84)
      implementation.
      
      Note: Although the ultimate goal is to remove the dynamic params from
      the response body (e.g. FlightRouterState), I have not done so yet this
      PR. The rest of the work will be split up into multiple subsequent PRs.
      e8b99e14
    • Janka Uryga's avatar
      [Cache Components] Runtime prefetching (#81088) · 1c5f64b9
      Janka Uryga authored
      Initial implementation of runtime prefetching.
      
      A "runtime prefetch" is a more complete version of a static prefetch
      (i.e. the one that a link does by default), rendered on demand, and not
      cached server-side. It will render the server part of the page
      dynamically, allowing the usage of
      - `params` and `searchParams`
      - `cookies()`
      - `"use cache: private"` (these are omitted from static prerenders)
      - `"use cache"` with a short expire time (these are omitted from static
      prerenders)
      
      The result may be partial (in the PPR sense). It will exclude any parts
      of the page that depend on
      - uncached IO
      - `connection()`, `headers()`
      This allows the client router to cache the result, because it has a
      well-defined stale time. Note that public caches with a stale time below
      a certain fixed treshold will also be excluded, because it wouldn't make
      sense to keep them around in the router cache if we need to throw them
      away soon after getting them.
      
      With this PR, `<Link prefetch={true}>` changes meaning
      if `clientSegmentCache` + `cacheComponents` are enabled. It will now
      initiate a runtime prefetch instead of a "full" prefetch, which included
      everything that a navigation request would. Full prefetches can be done
      via `<Link prefetch="unstable_forceStale">`. If only one of the two
      flags is on, the behavior of `<Link prefetch={true}>` is unchanged from
      how it currently works.
      
      I've split the changes up into separate commits for ease of review:
      1. Introducing the new workUnitStore type
      2. Server - handling the prefetch header and rendering
      3. Client - Link and segment cache changes
      
      ### Implementation notes
      
      The client router sends `next-router-prefetch: 2` to signal that it
      wants a runtime prefetch (as opposed to the old `next-router-prefetch:
      1`, which is used for static prefetches).
      
      > NOTE: this builder change is required for this to work on vercel
      https://github.com/vercel/vercel/pull/13547. It was released in
      `vercel@44.6.5`
      
      Somewhat confusingly, in order to to avoid existing static prefetch
      codepaths, we need the server to _not_ treat this as "a prefetch
      request". Instead, we want to mostly treat this like we would a
      navigation request, and render dynamically. This means that:
      - `isPrefetchRequest` (from `parseRequestHeaders` in `app-render`) will
      be `false`
      - `getRequestMeta(req, 'isPrefetchRSCRequest')` won't be set
      
      This is a bit ugly but it works for now. I'll try to clean it up in the
      future.
      
      We render a payload of the same shape as a navigation request (including
      omitting shared layouts, as instructed by the `Next-Router-State-Tree`
      header). But unlike a navigation request, we do a cache-components-style
      prerender at runtime in order to exclude uncached/sync IO.
      
      This prerender uses a new workUnitStore type, `'prerender-runtime'`.
      This store type changes the behavior of `cookies()`, `params`,
      `searchParams`, `"use cache: private"`, `next/root-params`, and others.
      Unlike a static prerender, if we detect a bad uncached/sync IO usage, we
      just log an error (instead of throwing it and erroring) and respond with
      whatever we managed to render up until the render was aborted, in hopes
      that we can still return something useful to the client. This request is
      happening at runtime, so we should try to handle errors gracefully.
      
      We track whether or not the prerender has any dynamic holes, and if it
      does, set `x-nextjs-postponed: 1` on the response. This tells the client
      router if we still need to fetch more data when navigating, or if we can
      skip it because we already have a complete page. Ideally, we'd track
      this information per-segment for better reuse on the client side, but
      that's not in scope for this PR.
      
      We also set the `x-nextjs-staletime` header on the response to tell the
      client router how long it should keep this prefetch in the cache. Note
      that this does not affect `Cache-Control`, which should still be the
      same as a dynamic navigation request to prevent it from being cached by
      anything other than the client router.
      This may be improved in the future if it turns out we can safely set an
      appropriate `Cache-Control: private, ...` that also accounts for e.g.
      changing cookie values, but i'm erring on the side of caution for now.
      1c5f64b9
    • nextjs-bot's avatar
    • Joshua Hannaford's avatar
      fix(Turbopack): Fix duplicated layout rendering in edge cases (#81948) · c6cefce4
      Joshua Hannaford authored
      ## Fix module reference handling in app_structure.rs creating duplicated layouts
      
      ### What?
      Fixed a bug in the `check_and_update_module_references` function by
      making the code always overrides the `not-found`, `unauthorized`, etc
      files at the top level group route layer.
      
      ### Why?
      The previous implementation had a bug that when a directory was setup
      like the added test case where the layouts from a lower directory would
      render when only the layouts at the level of the not-found page should
      have rendered.
      
      ### How?
      - Added the ability to force overriding of the `module` when running
      `check_and_update_module_references`
      - Split the logic between global and layer-specific modules
      
      Fixes #PACK-5081
      c6cefce4
    • Niklas Mischkulnig's avatar
      Turbopack: fix dev test manifest (#82241) · e2b6a50a
      Niklas Mischkulnig authored
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      ### Improving Documentation
      
      - Run `pnpm prettier-fix` to fix formatting issues before opening the PR.
      - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide
      
      ### Adding or Updating Examples
      
      - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
      - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md
      
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to understand the PR)
      - When linking to a Slack thread, you might want to share details of the conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic behind a change
      
      ### What?
      
      ### Why?
      
      ### How?
      
      Closes NEXT-
      Fixes #
      
      -->
      e2b6a50a
    • Dario Lehmhus's avatar
      2bb227eb
    • nextjs-bot's avatar
      v15.4.2-canary.24 · 189f971f
      nextjs-bot authored
      189f971f
    • Vercel Release Bot's avatar
      Update Rspack development test manifest (#82227) · f618d0b7
      Vercel Release Bot authored
      This auto-generated PR updates the development integration test manifest
      used when testing Rspack.
      Co-authored-by: 's avatarnextjs-bot <it+nextjs-bot@vercel.com>
      f618d0b7
    • Tobias Koppers's avatar
      Turbopack: implement shutdown for backing storage correct (#82220) · 05bf9981
      Tobias Koppers authored
      ### What?
      
      This ensures next.js correctly waits for the turbopack shutdown to complete
      05bf9981
    • Andrew Clark's avatar
      Fix: Don't bail out of prefetch if head is missing (#82216) · 6b5fe463
      Andrew Clark authored
      This fixes an edge case where a Link is prefetched with prefetch={true},
      and the target page has a dynamic head, but the head is not fully
      prefetched. If all the segment data for the target page was already
      cached, the prefetch scheduler would bail out and skip the request.
      However, we typically rely on the data prefetch to fetch the metadata,
      so by skipping the data prefetch we were effectively also skipping the
      metadata.
      
      The fix in this PR is to check for this condition before bailing out of
      the request, and initiate a request anyway.
      
      However, this illustrates that we're not modeling the caching of
      metadata in a complete way. Currently it's stored on the same cache
      entry as the route tree, but they are not always fetched simultaneously
      (as in this regression case), so their lifetimes are not always aligned.
      We should consider either always fetching the metadata as part of the
      route tree prefetch, or caching metadata on a separate entry type. This
      would allow us to dedupe entries between URLs that rewrite to the same
      route, like we already do for segments. The circumstances that lead to
      this scenario are relatively rare, though, hence the temporary solution
      in this PR.
      6b5fe463
    • nextjs-bot's avatar
      v15.4.2-canary.23 · ccde68ff
      nextjs-bot authored
      ccde68ff
    • JJ Kasper's avatar
      Revert "Upgrade @vercel og (#82201)" (#82219) · e98f9589
      JJ Kasper authored
      This reverts commit ac5fdf56.
      
      Reverts https://github.com/vercel/next.js/pull/82201 as our E2E deploy
      tests are still failing it seems.
      
      x-ref:
      https://github.com/vercel/next.js/actions/runs/16636039524/job/47078880946#step:33:321
      e98f9589
    • JJ Kasper's avatar
      Revert "Initial MCP implementation (#81770)" (#82217) · d2f9c0f9
      JJ Kasper authored
      It seems after landing this we have broken some integration with `jest`
      so reverting while we get to the bottom of what change in this commit
      specifically caused the breakage.
      
      x-ref: [slack
      thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1753911647161469)
      d2f9c0f9
    • Vercel Release Bot's avatar
      Update Rspack development test manifest (#82192) · 47b361ec
      Vercel Release Bot authored
      This auto-generated PR updates the development integration test manifest used when testing Rspack.
      47b361ec
    • Vercel Release Bot's avatar
      Update Rspack production test manifest (#82108) · 01b485dd
      Vercel Release Bot authored
      This auto-generated PR updates the production integration test manifest used when testing Rspack.
      01b485dd
  3. 30 Jul, 2025 18 commits