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

Turbopack Mishandles Child_process.Fork() Argument As Module Request

Turbopack's static analysis incorrectly treats the first argument of child_process.fork() as a module import, causing build failures when the argument is a dynamic path or absolute literal.

highConfidence 85%Next.jsAffected V16.0.0-Canary.0Affected V16.0.0Affected V16.3.3Affected V16.4.0-Canary.7Affected V16.4.0-Canary.8

Origin Analysis

Turbopack's dependency collector does not distinguish between module imports and arguments to Node.js child_process.fork(), so it attempts to resolve any statically analyzable string as a module path, which is a design flaw in the Turbopack module resolution logic.
1. Clone https://github.com/taracutie/nextjs-turbopack-repro\n2. Run npm ci\n3. Run npm run build\n4. Observe Turbopack build error: Module not found for the path passed to fork()

Fixing Code Block

Edge Case Audit

Using spawn with IPC requires careful handling of the child process, as it may behave slightly differently from fork (e.g., default environment, serialization). Additionally, if you rely on fork's built-in silent option or special message serialization, you must test thoroughly. Roll back to fork once the official Turbopack fix is released, and ensure your environment variables are removed if you previously used them.

Ecosystem Topology