fix(turbopack): handle cyclic or rootless nodes in ModuleGraphImportTracer - #98204
Open
agentHits wants to merge 1 commit into
Open
fix(turbopack): handle cyclic or rootless nodes in ModuleGraphImportTracer#98204agentHits wants to merge 1 commit into
agentHits wants to merge 1 commit into
Conversation
…racer Avoid unreachable!() panic when astar cannot find a path to a root in reversed_graph. Fallback gracefully to returning the current module index instead of crashing the entire build worker.
Author
|
Fixes #98205 Linked Issue: #98205 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
In
turbopack/crates/turbopack-core/src/module_graph/mod.rs, replacesunreachable!("there must be a path to a root")with a graceful fallback tovec![module_idx]whenastarcannot find a root in the reversed graph.Why?
During standalone static prerendering with complex CSS / SCSS import trees, when Turbopack formats an issue diagnostic via
ModuleGraphImportTracer::get_traces, cyclic imports or orphaned asset nodes can causeastaronreversed_graphto returnNone(since no node satisfiesneighbors(n).next().is_none()).Previously, this triggered an unexpected Rust panic that killed the entire build worker:
How?
Instead of panicking with
unreachable!, Turbopack now falls back to returning the singlemodule_idxso issue reporting can proceed without terminating the process: