Skip to content

every unlisted dynamic param stores its own 404 under cache components #98027

Description

@skurekjakub

Link to the code that reproduces this issue

https://github.com/skurekjakub/next-unlisted-params-repro

To Reproduce

  1. npm install && npm run repro

Current vs. Expected behavior

Current

app/post/[slug]/page.tsx has a generateStaticParams that returns the complete list of slugs, and calls notFound() for anything else. With cacheComponents: true, every request for a slug that isn't on the list renders a 404 and then stores that 404 under its own path in the ISR store.

Since the possible param space is unbounded disk grows based on you cacheLife config for the route * number of 404 requests in that time interval - which for some legacy domains that have changed urls many times and have their stuff on botlists and god knows what can be a lot.

Expected

I expect some way to close the gap and give the runtime info that generateStaticParams is exhaustive (build-time known invariant) under cacheComponents and partialPrefetching without converting the route fully static.

I'm not sure if this is a bug or intended behavior, since workarounds such as proxy-level middleware can short-circuit and redirect to /_not-found as well, but its extra code and kind of cumebrsome?

Provide environment information

Operating System:
  Platform: linux
  Arch: arm64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Jun 18 21:38:49 UTC 2026
  Available memory (MB): 15762
  Available CPU cores: 18
Binaries:
  Node: 24.19.0
  npm: 11.17.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.3.3 // Latest available version is detected (16.3.3).
  eslint-config-next: N/A
  react: 19.2.6
  react-dom: 19.2.6
  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)

Other (Deployed)

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions