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

Next Dev Hangs Forever When Module Request Exceeds V8 Regexp Stack Limit In Bundled Enhanced-Resolve

Next.js webpack dev server never resolves requests for modules whose identifiers exceed ~8.39M characters because the vendored enhanced-resolve uses a regex that overflows V8's RegExp stack, throwing RangeError and leaving the compilation promise permanently pending.

highConfidence 95%Next.jsApp RouterTurbopackServer ActionsAffected V15.5.18Affected V16.3.1-Canary.16

Origin Analysis

The bundled webpack in next/dist/compiled/webpack/bundle5.js contains an outdated enhanced-resolve whose parseIdentifier function runs the regex /^(#?(?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/ on every module request. For inputs above V8's RegExp stack limit (~8,388,572 chars), RegExp.exec throws RangeError: Maximum call stack size exceeded. The error is emitted as an unhandledRejection, not handled by the dev compiler, so the pending request never resolves.
1. git clone https://github.com/MuzajsArcin/nextjs-dev-hang-repro 2. cd nextjs-dev-hang-repro && npm install 3. node generate.mjs 8388573 # writes src/big.mjs with one 8,388,573-char data: URI 4. npm run dev 5. curl --max-time 60 http://localhost:3247/ -> never responds; dev server prints ○ Compiling / ... and RangeError: Maximum call stack size exceeded

Fixing Code Block

Edge Case Audit

This is a development-only workaround and should be removed once the bundled enhanced-resolve is updated. It only bypasses the regex for the specific pattern and inputs without null bytes; if a future request contains a null byte and is also extremely large, the original regex path may still overflow. Global monkey-patching RegExp.prototype.exec could theoretically affect other libraries that rely on exact regex execution semantics, but the scope is limited to the target source. To roll back, delete or comment out the patch block in next.config.js and restart the dev server.

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