vercel / vercel/next.js

Incorrect error message when awaiting params underneath 'use cache'

Open
#98,173 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/mdj-uk/next-bad-error-message/tree/37cf318e579a31ec0dca77e209ac89b5b8502d70

To Reproduce
  1. start app in dev
  2. navigate to dynamic route b

You'll see error message "Route /[slug] used searchParams inside "use cache"...." even though searchParams are not used

Current vs. Expected behavior

There's an error due to calling await params in a 'use cache' context. The error should refer to params. But instead it refers to searchParams.

In stable (16.3.4) the full error is

Route /[slug] used searchParams inside "use cache". Accessing dynamic request data inside a cache scope is not supported. If you need some search params inside a cached function await searchParams outside of the cached function and pass only the required search params as arguments to the cached function. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache

In canary ( 16.4.0-canary.13), error message is slightly different:

Route "/[slug]": searchParams can't be read inside "use cache". Await it outside the cached function and pass what you need as an argument. Learn more: https://nextjs.org/docs/messages/next-request-in-use-cache

Provide environment information
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 26.8.1
  npm: 8.15.0
  Yarn: N/A
  pnpm: 12.1.0
Relevant Packages:
  next: 16.3.4 // Latest available version is detected (16.3.4).
  eslint-config-next: N/A
  react: 19.2.8
  react-dom: 19.2.8
  typescript: 5.9.3
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

Use Cache

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

next dev (local)

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the linked reproduction app with next dev and navigating to dynamic route b. Trace the use cache error handling for await params, then verify that the reported message identifies params rather than searchParams and matches the expected behavior described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.