AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

404 Page Isn'T Server Rendered When Using NotFound()

When calling notFound() inside a page component in Next.js App Router, the initial server response contains only client-side script tags, not the server-rendered Not Found page HTML. This affects both development and production, including static pages returning incorrect 200 status in production.

highConfidence 85%Next.jsReact Server ComponentsPages RouterAffected V14.1.0

Origin Analysis

In Next.js App Router, the notFound() function throws a special error that is caught by the framework's error boundary, but for statically optimized pages the Not Found boundary is not rendered on the server. Instead, the client receives a generic client-side rendered shell, and the not-found UI is only hydrated on the client. This design flaw prevents server-side rendering of the 404 page and leads to incorrect HTTP status codes for static routes.
1. Create a new Next.js project using `npx create-next-app@latest`. 2. In app/page.tsx (or any page), call `notFound()` from `next/navigation`. 3. Start the app with `next dev` or `next build && next start`. 4. Open the page in a browser and inspect the network response. The response body contains only script tags, not the rendered HTML of the 404 page. 5. Compare with a non-existent route: the default Not Found page is server-rendered.

Fixing Code Block

Edge Case Audit

This workaround disables static optimization for the route, potentially increasing server load and response time. It is incompatible with `output: 'export'` (static export). If a future Next.js version fixes the underlying bug, this workaround should be removed to restore static optimization. Rollback: remove the `export const dynamic` line from the page.

Ecosystem Topology

Agent Frameworks

LangChain, LlamaIndex, and Pydantic

  1. highProperty graph relation keys collide when entity IDs or labels contain underscores
  2. highCodeActAgent drops assistant tool-call metadata during handoff, leaving an orphan tool response
  3. high[Bug]: HierarchicalNodeParser async methods return the documents unsplit
  4. highLLM.predict_and_call fails with ValidationError for non-function-calling models when react_chat_formatter is omitted
  5. highAnthropic streaming server-tool input_json_delta overwrites completed client tool_use arguments due to stale cur_tool_call state