Skip to content

"use cache" doesn't work for route handlers #76612

@6TELOIV

Description

@6TELOIV

Link to the code that reproduces this issue

https://github.com/6TELOIV/use-cache-route-handler-repro

To Reproduce

  1. Start dev (npm run dev)
  2. Visit http://localhost:3000/string
    • Observe the response
  3. Visit http://localhost:3000/response
    • Observe the error

Current vs. Expected behavior

With the current static/dynamic routes implementation, A dev can mark a route handler's GET method "static".

With the new "use cache" directive, this doesn't seem to work at all. Additionally, the error message seems opaque/confusing, refering to client and server components even though the method does nothing react-ish:

[Error: Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported.
  {}] {
  environmentName: 'Cache',
  digest: ''
}

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Enterprise
  Available memory (MB): 32401
  Available CPU cores: 8
Binaries:
  Node: 22.11.0
  npm: 10.9.0
  Yarn: 1.22.22
  pnpm: 10.5.2
Relevant Packages:
  next: 15.2.1-canary.1 // Latest available version is detected (15.2.1-canary.1).
  eslint-config-next: 15.2.1-canary.1
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

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

dynamicIO, Use Cache

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

next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)

Additional context

Failing in 15.2.1-canary.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dynamicIORelated to dynamicIO.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions