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

Turbopack Production Build Deadlocks On Circular Async Chunk References With Content Hashing

Next.js 16.3.1 Turbopack production builds hang indefinitely at 0% CPU when mutually-referencing async chunks are merged and content hashing is enabled. The hang is caused by a dependency cycle: chunk paths depend on their own content hash, while chunk content depends on other chunk paths. turbo-tasks has no cycle detection, leading to a silent deadlock.

criticalConfidence 95%Next.jsAffected V16.1.0Affected V16.3.1

Origin Analysis

Production client chunking uses ContentHashing::Direct. A chunk's path is derived from a hash of its own content. The chunk's content includes async loader modules that embed the paths of referenced chunk groups. When the chunk graph contains a cycle (mutual dynamic imports across merged chunks), each chunk's path transitively awaits itself. turbo-tasks assumes task cycles are impossible and waits on done_event without detection, causing a deterministic deadlock.
1. Create or use a large Next.js app (e.g., ~24k modules) with Turbopack enabled and multiple dynamic import() calls that form a reference cycle after chunk merging. 2. Run 'next build' with Next.js 16.1.0 or 16.3.1. 3. Observe that compilation proceeds normally for a few minutes then stops at 'Creating an optimized production build ...' with 0% CPU and never completes. 4. The small public reproduction (https://github.com/swarupdonepudi/turbopack-chunk-name-cycle) does not trigger the hang due to scale; the cycle requires specific chunk merging conditions.

Fixing Code Block

Edge Case Audit

Using Ident-based hashing changes output file names and may affect long-term caching or deployment assumptions. Users should treat this as a temporary patch and not rely on it for production releases. Rollback by reverting to the original line. For a more complete fix, extend the estimated placeholder mechanism to break cycles or add cycle detection in turbo-tasks.

Ecosystem Topology