fix: infinite loop in is_available_chunk when chunk groups form a cycle#13042
fix: infinite loop in is_available_chunk when chunk groups form a cycle#13042
is_available_chunk when chunk groups form a cycle#13042Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a potential infinite loop in ChunkGraph’s is_available_chunk traversal when chunk group parent relationships contain cycles, and adds/updates stats output test cases to cover the scenario.
Changes:
- Add cycle detection to
is_available_chunkby deduplicating visited chunk groups during parent traversal. - Update the existing
limit-chunk-count-pluginstats case to includedependentModulesoutput (and snapshot updates). - Add a new
statsOutputCases/issue-12572regression case + snapshot.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
crates/rspack_core/src/chunk_graph/chunk_graph_chunk.rs |
Prevents infinite traversal by tracking visited chunk groups while walking parents. |
tests/rspack-test/statsOutputCases/limit-chunk-count-plugin/rspack.config.js |
Enables dependentModules in stats output for the case. |
tests/rspack-test/statsOutputCases/limit-chunk-count-plugin/index.js |
Adjusts test inputs to exercise dependent module reporting (and triggers expected warning output). |
tests/rspack-test/statsOutputCases/limit-chunk-count-plugin/__snapshots__/stats.txt |
Updates snapshot to match the new stats output (including warnings). |
tests/rspack-test/statsOutputCases/issue-12572/rspack.config.js |
Adds new regression config for the cycle scenario with LimitChunkCountPlugin. |
tests/rspack-test/statsOutputCases/issue-12572/index.js |
New entry creating the relevant async import graph. |
tests/rspack-test/statsOutputCases/issue-12572/main.js |
Part of the circular async import graph used by the regression. |
tests/rspack-test/statsOutputCases/issue-12572/a.js |
Part of the circular async import graph used by the regression. |
tests/rspack-test/statsOutputCases/issue-12572/b.js |
Part of the circular async import graph used by the regression. |
tests/rspack-test/statsOutputCases/issue-12572/__snapshots__/stats.txt |
Snapshot for the new regression case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/rspack-test/statsOutputCases/issue-12572/rspack.config.js
Outdated
Show resolved
Hide resolved
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 1 project with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 ui-componentsPath:
📦 Download Diff Report: ui-components Bundle Diff Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
❌ Size increased by 640bytes from 48.68MB to 48.68MB (⬆️0.00%) |
Merging this PR will not alter performance
Comparing Footnotes
|
Summary
Fix #12572
Fix infinite loop in
is_available_chunkwhen chunk groups form a cycle.The
is_available_chunkfunction could enter an infinite loop when chunk groups have circular dependencies. The function traverses parent chunk groups without tracking visited nodes, causing it to revisit the same chunk groups indefinitely when cycles exist.Add cycle detection to prevent infinite loops when traversing chunk group hierarchies. The function now tracks visited chunk groups to avoid processing the same group multiple times.
Related links
Checklist