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

Global-Error.Tsx Not Rendered For Errors During "Use Cache" Route Regeneration In Production

In Next.js 16.3.0-canary.107, when a production route using "use cache" throws an error during regeneration, the global-error.tsx component is not rendered. Instead, the server returns a plain text 'Internal Server Error'. Dynamic routes correctly trigger global-error.tsx, indicating a bug in the cache regeneration error handling path.

highConfidence 75%Next.jsPages RouterTurbopackAffected V16.3.0-Canary.107

Origin Analysis

The error during "use cache" route regeneration is not passed to React's error boundary or the global-error handler because the cache regeneration process occurs outside the normal React rendering tree. The error handler in the cache regeneration path falls back to a plain text response instead of rendering the global-error component.
1. Clone the reproduction repo: https://github.com/amjedomar/next-cache-and-global-error-handler-bug 2. Install dependencies: npm install 3. Build and start production: npm run build && npm start 4. Visit http://localhost:3000/cached (initially works) 5. Invalidate cache: curl -X POST http://localhost:3000/api/invalidate 6. Refresh http://localhost:3000/cached 7. Observe that global-error.tsx is not rendered, only 'Internal Server Error' text. Compare with http://localhost:3000/dynamic which renders global-error.tsx correctly.

Fixing Code Block

Edge Case Audit

Applying this fix requires modifying Next.js internal source code or patching the installed package, which may be overwritten on next update. It may also cause infinite loops if global-error.tsx itself throws or if the reset function is not correctly provided. In concurrent cache regeneration scenarios, multiple error responses may race; ensure proper synchronization on the reset callback. Rollback: if any unexpected behavior occurs, revert to the original code and wait for an official Next.js fix.

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