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

App Router: Flight Decode Executes Incompatible Modules Before Build Mismatch Recovery During Rolling Deploy

During rolling deployments with version skew (Build A browser, Build B server), Next.js App Router may decode Flight responses before verifying build ID, causing fatal runtime errors like TypeError or ChunkLoadError.

highConfidence 85%Next.jsnext buildPages RouterServer ActionsAffected V16.1.5

Origin Analysis

In `fetch-server-response.ts`, `createFromNextFetch` is called to decode the Flight response before the build mismatch check (`flightResponse.b !== currentBuildId`) runs. This allows incompatible module references from Build B to be resolved and evaluated in a Build A runtime, leading to export shape errors or chunk loading failures.
1. Clone https://github.com/wa3l/nextjs-version-skew-repro 2. Install dependencies 3. Run ./scripts/reproduce.sh 4. Open http://localhost:3000 immediately 5. In DevTools Console, enable Preserve log 6. Wait for deploy message (~10s) 7. Click Other Page 8. Observe Uncaught TypeError: (0, n.tripleCount) is not a function or ChunkLoadError

Fixing Code Block

Edge Case Audit

This fix assumes the server sends `x-build-id` on RSC responses. If the header is missing or cached incorrectly by a CDN, the early check may be bypassed and the original bug persists. Forcing `window.location.reload()` can cause infinite reload loops if the server and client build IDs never match due to a deployment issue or rollback. In multi-tab or concurrent sessions, reload may disrupt user state. It also requires coordination with server deployment: the header must be present before client code is deployed. Rollback: remove the early check and rely on the existing post-decode recovery. Test with feature flag and ensure no reload loop when a previous build is served.

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