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

Dev Server Reads Zero-Byte Emitted Manifests During Rebuild Causing 500 Errors

In Next.js dev server (webpack), in-flight requests can read bundler-emitted manifests while they are zero bytes, leading to 'Manifest file is empty' or JSON parse errors. Occurs when concurrent requests overlap a rebuild; verified on next@16.3.0/16.3.1/canary.

highConfidence 92%Next.jsServer Actionsnext buildHydrationAffected V16.3.0Affected V16.3.1Affected Vcanary

Origin Analysis

RouteModule loads manifests with shouldCache: !this.isDev, so every request re-reads manifest files from disk. The bundler rewrites these files on each rebuild. A request landing between file creation and content write reads a zero-length file. The file is not torn but remains empty for a sustained window, so short retries fail. handleMissing only covers absent files, not empty existing files.
1. Clone https://github.com/Faolain/nextjs-dev-manifest-empty-race 2. Run npm install 3. Run npm run repro (boots dev server, hammers 12 App Router routes for 90s) 4. Script prints REPRODUCED and exits 0 when error appears in dev.log (usually within 30s). 5. Observe error: 'Error: Manifest file is empty' or 'SyntaxError: Unexpected end of JSON input'.

Fixing Code Block

Edge Case Audit

The fallback cache may serve stale manifest content during the zero-byte window; this could temporarily expose outdated client references or font data. After the rebuild completes, the cache refreshes on the next successful read. Risk of infinite waiting is bounded by MAX_EMPTY_RETRIES. The sync sleep uses SharedArrayBuffer, which requires a compatible Node runtime (Node 10+ with flag, Node 20+ default). In multi-threaded or worker contexts, the module-level fallbackCache is shared but reads/writes are synchronous, so no race within a single process; in cluster mode each worker has its own cache, which is acceptable. If a manifest legitimately becomes empty (should not happen), the fallback masks the error. Rollback: revert to the original loader files and remove the fallback; no database or external state is modified.

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