Skip to content

Global not-found page interferes with static rendering #71623

Open
@amannn

Description

@amannn

Link to the code that reproduces this issue

https://github.com/amannn/nextjs-bug-repro-not-found

To Reproduce

  1. Clone https://github.com/amannn/nextjs-bug-repro-not-found
  2. Run pnpm i
  3. Run pnpm build

Current vs. Expected behavior

This commit outlines the issue: f5cbf18

The not-found page is dynamic, while / is expected to render statically. However, somehow the global not found page is rendered as part of /.

Output:

  ▲ Next.js 15.0.1-canary.1

   Creating an optimized production build ...

warn - No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.
warn - https://tailwindcss.com/docs/content-configuration
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
   Generating static pages (0/4)  [==  ]
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error

Error: Route / with `dynamic = "error"` couldn't be rendered statically because it used `headers`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering
Export encountered an error on /page: /, exiting the build.
 ⨯ Static worker exited with code: 1 and signal: null
   Generating static pages (1/4)  [    ] ELIFECYCLE  Command failed with exit code 1.

I'd expect the 404 page to be dynamic while the home page is static.

Provide environment information

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 12
Binaries:
  Node: 20.11.1
  npm: 10.2.4
  Yarn: 1.22.22
  pnpm: 9.12.2
Relevant Packages:
  next: 15.0.1-canary.1 // Latest available version is detected (15.0.1-canary.1).
  eslint-config-next: 15.0.1-canary.1
  react: 19.0.0-rc-69d4b800-20241021
  react-dom: 19.0.0-rc-69d4b800-20241021
  typescript: 5.6.3
Next.js Config:
  output: N/A

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

Output (export/standalone), Runtime

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

next build (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Error HandlingRelated to handling errors (e.g., error.tsx, global-error.tsx).linear: nextConfirmed issue that is tracked by the Next.js team.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions