Skip to content

Mutating cookies in a server action under a next/root-params route throws an error #82302

@apostolos

Description

@apostolos

Link to the code that reproduces this issue

https://github.com/apostolos/nextjs-root-params-action-cookie

To Reproduce

  1. Start the application in development node --run dev
  2. Open the test page http://localhost:3000/en-GB
  3. Click on the button to execute the Server Action

Current vs. Expected behavior

Current behavior

Clicking on the button executes the server action and sets the cookie, however it immediately throws an error with the following message:

Image

Expected

The server action should execute and the page should be revalidated without issue.

Notes

Notice that the code in actions.ts DOES NOT access next/root-params at all.

The problem occurs due to the following two rules/behaviors:

  • next/root-params are not supposed to be imported/used in server actions because actions are not tied to a specific route.
  • Mutating cookies in a server action, causes a full page/layout re-render. This happens to avoid stale RSC state.

So as far as I can tell, what happens is the code that tracks root-params access inside server actions incorrectly considers the route revalidation+rendering as part of the action execution.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:25 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6020
  Available memory (MB): 32768
  Available CPU cores: 12
Binaries:
  Node: 24.5.0
  npm: 11.5.2
  Yarn: 1.22.22
  pnpm: 9.15.9
Relevant Packages:
  next: 15.4.2-canary.27 // Latest available version is detected (15.4.2-canary.27).
  eslint-config-next: N/A
  react: 19.1.1
  react-dom: 19.1.1
  typescript: N/A
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Server Actions

Which stage(s) are affected? (Select all that apply)

next dev (local), next start (local)

Additional context

Bug introduced in #80255

Happens in both dev & production builds.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions