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

[Bug] Interception Routes Break On Every HMR Save In Next.Js 16 — "Invalid Interception Route" Error

In Next.js 16 with Turbopack, interception route rewrites accumulate in the dev server's beforeFiles array on every HMR update, leading to invalid route errors and requiring a full restart.

highConfidence 95%Next.jsPages RouterHydrationnext buildAffected V16.1.6

Origin Analysis

During each HMR update, setup-dev-bundler.js pushes interception route rewrites into fsChecker.rewrites.beforeFiles without removing previously added entries. This causes the intercepting route path to be prefixed with multiple (.) markers, producing patterns like /users/(.)(.)(.)1 and violating the expected format.
1. Create a new Next.js 16 project using npx create-next-app@latest 2. Create the following files: app/users/@modal/(.)[id]/page.tsx, app/users/@modal/default.tsx, app/users/[id]/page.tsx, app/users/layout.tsx (renders children and modal slots), app/users/page.tsx 3. Start the dev server: npm run dev 4. Navigate to http://localhost:3000/users 5. Click a card to open the modal 6. Save any file in the project (add a space and save) 7. Observe the terminal error: Invalid interception route: /users/(.)(.)(.)1 8. Note that the number of (.) markers increases with each save, confirming accumulation. A full dev server restart is required to temporarily resolve it.

Fixing Code Block

Edge Case Audit

This fix assumes that isInterceptionRouteRewrite correctly identifies all interception route rewrites. If the function is inaccurate, it may inadvertently remove non-interception routes or fail to remove some interception routes. Additionally, replacing the entire beforeFiles array may break references held elsewhere in the system; ensure that no other code holds a direct reference to the old array. Edge cases to test include nested intercepting routes, dynamic segments, and multiple HMR saves in rapid succession. Rollback suggestion: if issues arise, revert to a full dev server restart as a temporary workaround, or downgrade to Next.js 15.2.4 where this code path does not exist.

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