next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Internal Server Error on dynamic routes with %25 in the dynamic param with cacheComponents enabled

Open therungg opened this issue 1 month ago • 1 comments

Link to the code that reproduces this issue

https://github.com/therungg/next-percentage-cache-bug-repro

To Reproduce

  1. Enable cacheComponents in next.config.ts
  2. Create a dynamic route
  3. Start the application with npm run build && npm run start (it is not reproducable with npm run dev)
  4. Navigate to http://localhost:3000/%25
  5. Page breaks

Any dynamic route with %25 in the parameter breaks. %24 or other url encoded characters work fine.

Breaks on both Turbopack and Webpack

Disabling cacheComponents removes the bug

Current vs. Expected behavior

When navigating to a dynamic route with a %25 anywhere in the dynamic parameter, and I have cacheComponents enabled, it will give a 500 Internal Server Error.

I expect the page to load fine and to url-decode the character correctly to %.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun  5 18:30:46 UTC 2025
  Available memory (MB): 8937
  Available CPU cores: 16
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.0.0
Relevant Packages:
  next: 16.1.0-canary.16 // Latest available version is detected (16.1.0-canary.16).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

cacheComponents

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

next start (local)

Additional context

No response

therungg avatar Dec 08 '25 23:12 therungg

Looked into it some more: turns out somewhere earlier, the param was already urldecoded. This could be in a lot of places and for a lot of purposes, so I think the best fix is to make sure the param is not already decoded.

I submitted a PR to fix this

therungg avatar Dec 09 '25 23:12 therungg