next.js: staticGenerationBailout causes non-dismissable error overlay in dev mode

Verify canary release

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

Provide environment information

sandbox@sse-sandbox-fyyk70:/sandbox$ npx next info

    Operating System:
      Platform: linux
      Arch: x64
      Version: #45~20.04.1-Ubuntu SMP Mon Apr 4 09:38:31 UTC 2022
    Binaries:
      Node: 16.15.1
      npm: 8.11.0
      Yarn: 1.22.19
      pnpm: N/A
    Relevant packages:
      next: 13.0.5-canary.3
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Describe the Bug

When using cookies() anywhere inside a (potentially) static layout, next throws an Error: Dynamic server usage: cookies.

Example use case:

  • /[organization]/homepage, /[organization]/about, … → static, generateStaticParams implemented in organization segment layout
  • /[organization]/admin → fully dynamic, as data depends on the user who is logged in (through cookie)

Expected Behavior

I would expect Next to just exit out of static generation for this /[organization]/admin subpath, without throwing an error.

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://codesandbox.io/s/blissful-napier-fyyk70?file=/app/[organization]/admin/page.tsx

To Reproduce

Go to https://fyyk70.sse.codesandbox.io/myorg/admin

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (2 by maintainers)

Most upvoted comments

This seems to be fixed in the 13.0.7, I can’t reproduce it anymore locally or in the Sandbox.