Link to the code that reproduces this issue
https://github.com/agentHits/next-prerender-workstore-reproduction
To Reproduce
- Clone reproduction repository:
git clone https://github.com/agentHits/next-prerender-workstore-reproduction.git
cd next-prerender-workstore-reproduction
bun install # or npm install
- Run a cold static export build without
experimental.inlineCss: true:
rm -rf .next
bun run build # or next build
- On projects with standalone output and complex CSS/SCSS modules, Turbopack panics in the Rust runtime:
thread 'tokio-rt-worker' panicked at turbopack/crates/turbopack-core/src/module_graph/mod.rs:750:25:
internal error: entered unreachable code: there must be a path to a root
Debug info:
- Execution of emit_all_output_assets_once_with_issues_operation failed
- Execution of PlainIssue::from_issue failed
- Execution of <ModuleGraphImportTracer as ImportTracer>::get_traces failed
- internal error: entered unreachable code: there must be a path to a root
Current vs. Expected behavior
Current Behavior:
When formatting an issue/warning trace during CSS chunk emission (emit_all_output_assets_once_with_issues), ModuleGraphImportTracer::get_traces executes astar searching for a node with no incoming edges in the reversed graph (|n| reversed_graph.neighbors(n).next().is_none()).
If the module subgraph contains cyclic references or disconnected nodes, astar returns None, triggering the panic unreachable!("there must be a path to a root") at line 750, terminating the entire build process.
To avoid this crash, developers are forced to enable experimental.inlineCss: true, which bypasses external CSS chunking by serializing all CSS text chunks directly into the RSC Flight stream (self.__next_f), inflating document HTML size from ~150 KB to >700 KB and causing significant Core Web Vitals regressions (LCP: 8.9s vs 2.1s).
Expected Behavior:
Turbopack should handle cyclic or rootless subgraphs gracefully by falling back to returning the current module index instead of panicking.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.6.0
Binaries:
Node: 24.20.0
npm: 11.19.0
Yarn: N/A
pnpm: 11.19.0
Relevant Packages:
next: 16.3.4 (and canary 16.4.0-canary.15)
react: 19.2.8
react-dom: 19.2.8
typescript: 6.0.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack, CSS, Performance
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
A complete Rust pull request with the fix has been submitted:
👉 PR: #98204
Fix in turbopack/crates/turbopack-core/src/module_graph/mod.rs:
let path = match petgraph::algo::astar(
&reversed_graph,
module_idx,
|n| reversed_graph.neighbors(n).next().is_none(),
|e| match e.weight().chunking_type {
ChunkingType::Parallel { .. } => 0,
_ => 1,
},
|_| 0,
) {
Some((_, path)) => path,
None => vec![module_idx],
};
Link to the code that reproduces this issue
https://github.com/agentHits/next-prerender-workstore-reproduction
To Reproduce
experimental.inlineCss: true:rm -rf .next bun run build # or next buildCurrent vs. Expected behavior
Current Behavior:
When formatting an issue/warning trace during CSS chunk emission (
emit_all_output_assets_once_with_issues),ModuleGraphImportTracer::get_tracesexecutesastarsearching for a node with no incoming edges in the reversed graph (|n| reversed_graph.neighbors(n).next().is_none()).If the module subgraph contains cyclic references or disconnected nodes,
astarreturnsNone, triggering the panicunreachable!("there must be a path to a root")at line 750, terminating the entire build process.To avoid this crash, developers are forced to enable
experimental.inlineCss: true, which bypasses external CSS chunking by serializing all CSS text chunks directly into the RSC Flight stream (self.__next_f), inflating document HTML size from ~150 KB to >700 KB and causing significant Core Web Vitals regressions (LCP: 8.9s vs 2.1s).Expected Behavior:
Turbopack should handle cyclic or rootless subgraphs gracefully by falling back to returning the current module index instead of panicking.
Provide environment information
Which area(s) are affected? (Select all that apply)
Turbopack, CSS, Performance
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
A complete Rust pull request with the fix has been submitted:
👉 PR: #98204
Fix in
turbopack/crates/turbopack-core/src/module_graph/mod.rs: