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

Next.Js CacheComponents Poisoned By NotFound() Under Concurrent Requests

Under concurrent requests, a 404 response from one dynamic route is cached and served for another route that should return 200, leading to intermittent incorrect 404 pages on valid paths.

highConfidence 75%Next.jsApp RouterServer ActionsRoute HandlersAffected V16.1.0Affected V16.2.0-Canary.95

Origin Analysis

Race condition in Next.js cacheComponents when notFound() is thrown during rendering: the error boundary result is stored with an incorrect or shared cache key, allowing one path's 404 entry to overwrite another path's successful cached render.
1. Create a Next.js App Router project with a dynamic route app/pokemon/[id]/page.tsx that calls notFound() for invalid IDs. 2. Ensure cacheComponents is enabled (default in Next.js 16). 3. Run Playwright tests in multiple browsers concurrently, with one test visiting /pokemon/1 (valid) and another visiting /pokemon/1337 (invalid). 4. Observe that /pokemon/1 intermittently returns the 404 page.

Fixing Code Block

Edge Case Audit

This workaround disables caching for the entire route, which may increase server load and latency. It also prevents static generation for this route. Rollback by removing the `force-dynamic` export after upgrading to a Next.js version that fixes the cache poisoning. In a production environment, ensure all affected routes are consistently dynamic to avoid partial caching.

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