Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generateStaticParams runs in dev mode #44904

Open
1 task done
capJavert opened this issue Jan 15, 2023 · 0 comments
Open
1 task done

generateStaticParams runs in dev mode #44904

capJavert opened this issue Jan 15, 2023 · 0 comments
Labels
template: bug A user has filled out the bug report template. Issue needs triaging

Comments

@capJavert
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000
Binaries:
  Node: 18.13.0
  npm: 8.19.3
  Yarn: 1.22.18
  pnpm: 7.22.0
Relevant packages:
  next: 13.1.3-canary.0
  eslint-config-next: 13.1.2
  react: 18.2.0
  react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true)

Link to the code that reproduces this issue

https://github.com/vercel/app-playground

To Reproduce

Add generateStaticParams to ISR dynamic page and it will be run in dev mode. In the example above go to /app/isr/[id]/page.tsx and you will see that it is run in dev mode.

Describe the Bug

From my understanding generateStaticParams should be run only at build time, to quote the docs:

The generateStaticParams function runs at build time before the corresponding Layouts or Pages are generated. It will not be called again during revalidation (ISR).

Fetching data for pre-rendering in dev mode is kinda an overhead and waste of resources. For now I am using a workaround:

if (process.env.NODE_ENV === 'development') {
    return []
}

Expected Behavior

generateStaticParams runs only at build time.

Alternatively update the docs to reflect that this also runs in dev mode. I would imagine this is useful if you wish to test out the method. But in my opinion next build should be used to test it because it will have correct env and variables.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@capJavert capJavert added the template: bug A user has filled out the bug report template. Issue needs triaging label Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
template: bug A user has filled out the bug report template. Issue needs triaging
Projects
None yet
Development

No branches or pull requests

1 participant