vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.92k stars 26.98k forks source link

On demand revalidation removes statically generated pages with `generateStaticParams()` and `dynamicParams = false` #63479

Open Javad9s opened 7 months ago

Javad9s commented 7 months ago

Link to the code that reproduces this issue

https://github.com/Javad9s/nextjs-revalidate-breaks-static-params

To Reproduce

  1. Build and start the application (npm run build , npm start)
  2. Open http://localhost:3000/params/01 => returns Params : 01
  3. Open http://localhost:3000/ and click on Revalidate
  4. Open http://localhost:3000/params/01 => returns 404

Current vs. Expected behavior

Current : returns 404 after revalidation Expected : should return Params : 01 again

Provide environment information

Binaries:
  Node: 20.9.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.0-canary.31 // Latest available version is detected (14.2.0-canary.31).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.2
Next.js Config:
  output: N/A

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

App Router

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

next start (local)

Additional context

Any unexpected revalidation like revalidatePath("/", "layout") or revalidating a common cache tag will flush statically generated pages and we have to build the entire application again.

martin-coded commented 6 months ago

This is a problem that has been around for a long time. Good to know is, that it doesn't seem to happen when you deploy to Vercel.

https://github.com/vercel/next.js/issues/58137

szelpe commented 4 months ago

Hi. I've ran into the same bug having Next deployed with Docker

Binaries: Node: 20.11.1 npm: N/A Yarn: N/A pnpm: N/A Relevant Packages: next: 14.2.4 // Latest available version is detected (14.2.4). eslint-config-next: 14.1.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3

katarsistr commented 2 months ago

There is no problem when the dynamicParams setting is true. However, if the value of dynamicParams is false, a 404 error occurs. Shouldn’t there be no error even when it is false?