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

Global-Not-Found With Any Import Causes Infinite Dev Loop In Next.Js 16.2.X

When experimental.globalNotFound is enabled and no root layout is present, adding any import (e.g., CSS) to app/global-not-found.tsx triggers infinite recompilation in dev, spawning multiple Node processes and high CPU. Regression from 16.1.6.

highConfidence 85%Next.jsTurbopackPages RouterAffected V16.2.1Affected V16.2.2

Origin Analysis

The global-not-found page is incorrectly treated as a root layout entry in the module graph when no root layout exists, causing its imports to trigger repeated invalidation and recompilation loops in the dev server (likely Turbopack).
1. Create a new Next.js app with `pnpm create next-app@latest`. 2. Create route groups: `mkdir -p app/'(group1)' app/'(group2)'/path` and copy page/layout files accordingly. 3. Remove root layout and page: `rm app/page.tsx app/layout.tsx`. 4. Enable `experimental.globalNotFound` in next.config.ts. 5. Create `app/global-not-found.tsx` with an import (e.g., `import './globals.css';`). 6. Run `pnpm run dev`. The dev server enters an infinite loop with high CPU and multiple Node processes.

Fixing Code Block

Edge Case Audit

This workaround changes the component tree by adding a root layout. Ensure it does not break existing layouts or override nested layout behavior. To roll back, delete the root layout and restore the import in global-not-found. This does not fix the underlying Next.js bug; upgrade to a patched version when available.

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