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

Next Build Hangs When Static Generation Worker Batch Exceeds V8 Max String Length

When cacheComponents is enabled, the export worker serializes the entire batch of static pages' resume data caches into a single IPC message, exceeding Node's maximum string length. process.send throws RangeError: Invalid string length, which becomes an unhandledRejection, leaving the parent waiting indefinitely and causing the build to hang at 'Generating static pages'.

highConfidence 72%Next.jsApp RouterReact Server ComponentsAffected V16.4.0-Canary.58

Origin Analysis

In Next.js 16.4.0-canary.58, the static generation worker sends the complete batch result to the parent via a single process.send() IPC message. With cacheComponents, each page includes serialized resume data cache, making the aggregate serialized payload exceed V8's maximum string length (~536,870,888 characters). The resulting RangeError from process.send is not caught, triggering an unhandledRejection in the worker, and the parent never receives a result or error, causing a permanent hang. Underlying design flaw: IPC result transfer lacks chunking, streaming, or size validation.
1. Clone the reproduction repository: https://github.com/AdzerKI/next-export-batch-ipc-limit 2. Run `npm ci` 3. Run `npm run build` 4. Observe build hangs indefinitely at 'Generating static pages' (expected finish or explicit error).

Fixing Code Block

Edge Case Audit

This fix causes the build to fail instead of hang; it does not allow successful builds with large cacheComponents batch sizes. For production-scale static exports with heavy resume data, a more comprehensive solution involving chunked IPC or streaming is required. Rollback guidance: if this patch causes unexpected behavior, revert to the original process.send call and temporarily disable cacheComponents or reduce the number of pages per worker batch. In concurrent or multi-threaded builds, multiple workers may send error messages simultaneously; the parent must handle error events idempotently. If a future Next.js release introduces official chunking, this patch may conflict and should be removed.

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