nextjs - ✅(Solved) Fix notFound function does not render not-found page and instead causes page crash (App Router, Next 16) [1 pull requests, 9 comments, 8 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#90837Fetched 2026-04-08 00:19:24
View on GitHub
Comments
9
Participants
8
Timeline
21
Reactions
2
Author
Assignees
Timeline (top)
commented ×9referenced ×3cross-referenced ×2labeled ×2

Error Message

current: the site crashed. and you will see this message "Application Error" Error Handling, Use Cache, cacheComponents, Dynamic Routes

Fix Action

Fixed

PR fix notes

PR #92231: fix: preserve HTTP access fallbacks during prerender recovery

Description (problem / solution / changelog)

When a notFound(), forbidden(), or unauthorized() error escapes into the outer prerender recovery path, we were falling back to the generic error shell flow.

In the cacheComponents case, that could leave us with:

  • error HTML rendered from ErrorApp
  • Flight data reused from the aborted prerender prelude
  • references to Flight chunks that were never emitted

That is what caused the client-side Connection closed failure in #86251.

Instead of rerendering the full Flight tree or always using the generic error RSC payload, this change:

  • finds the deepest matching HTTP fallback boundary
  • rerenders the normal app router payload with that segment-scoped fallback
  • tees the replacement Flight stream so Fizz can render from one copy while prerender buffering consumes the other
  • only takes this path for recoverable HTTP access fallbacks that have a real boundary (ie a defined not-found/unauthorized/etc)

If no matching boundary exists, we keep the existing generic error handling.

Fixes #86251 Fixes #90837 Closes #87041 Closes #86251

Closes NAR-711 Closes NEXT-4876

Changed files

  • packages/next/src/server/app-render/app-render.tsx (modified, +119/-16)
  • packages/next/src/server/app-render/create-component-tree.tsx (modified, +75/-21)
  • test/e2e/app-dir/cache-components/app/cases/not-found-suspense/layout.tsx (added, +17/-0)
  • test/e2e/app-dir/cache-components/app/cases/not-found-suspense/not-found.tsx (added, +3/-0)
  • test/e2e/app-dir/cache-components/app/cases/not-found-suspense/page.tsx (added, +7/-0)
  • test/e2e/app-dir/cache-components/cache-components.test.ts (modified, +14/-0)

Code Example

Next.js: 16.x (also reproducible on latest canary)
React: 19.x
Router: App Router
Node.js: 22.x
Package manager: pnpm
OS: macOS 
(also reproducible on other team machines)
Browser: Chrome 145.x
Architecture: Dynamic route (/menu/category/[slug])
Data layer: External CMS (Prismic), but issue appears framework-level
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/alexismendez11/ecommerce-demo

To Reproduce

  1. Navigate to https://v0-ecommerce-next-js-app.vercel.app/menu
  2. Go to a non existent category page (ex. https://v0-ecommerce-next-js-app.vercel.app/menu/category/test)
  3. You will see the page crash with the message
<img width="3416" height="1614" alt="Image" src="https://github.com/user-attachments/assets/72a2fc15-405f-486e-bcc1-4dc21f2fa5c2" />

Current vs. Expected behavior

current: the site crashed. and you will see this message "Application Error" expected: see the content of the defined NotFound page

Provide environment information

Next.js: 16.x (also reproducible on latest canary)
React: 19.x
Router: App Router
Node.js: 22.x
Package manager: pnpm
OS: macOS 
(also reproducible on other team machines)
Browser: Chrome 145.x
Architecture: Dynamic route (/menu/category/[slug])
Data layer: External CMS (Prismic), but issue appears framework-level

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

Error Handling, Use Cache, cacheComponents, Dynamic Routes

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

next build (local), next start (local), Vercel (Deployed)

Additional context

No response

extent analysis

Fix: Add proper not-found.tsx handling and call notFound() in the dynamic route

The crash happens because the dynamic route /menu/category/[slug] never tells Next.js that the slug is invalid. When the CMS returns no data, the page throws an un‑caught error and the whole app falls back to the generic “Application Error”.
The fix is:

  1. Create a not-found.tsx component (or place one higher‑up) so Next can render a custom 404 for this segment.
  2. Detect a missing CMS entry in the page’s data‑fetching logic and invoke notFound() from next/navigation.
  3. (Optional) Add a generateStaticParams with `fallback:

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix notFound function does not render not-found page and instead causes page crash (App Router, Next 16) [1 pull requests, 9 comments, 8 participants]