Skip to content

Comments

fix: infinite loop in is_available_chunk when chunk groups form a cycle#13042

Merged
SyMind merged 3 commits intomainfrom
fix-can-chunks-be-integrated
Feb 11, 2026
Merged

fix: infinite loop in is_available_chunk when chunk groups form a cycle#13042
SyMind merged 3 commits intomainfrom
fix-can-chunks-be-integrated

Conversation

@SyMind
Copy link
Member

@SyMind SyMind commented Feb 11, 2026

Summary

Fix #12572

Fix infinite loop in is_available_chunk when chunk groups form a cycle.

The is_available_chunk function 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

  • Tests updated (or not required).
  • Documentation updated (or not required).

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: bug fix release: bug related release(mr only) labels Feb 11, 2026
@SyMind SyMind marked this pull request as ready for review February 11, 2026 06:16
Copilot AI review requested due to automatic review settings February 11, 2026 06:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_chunk by deduplicating visited chunk groups during parent traversal.
  • Update the existing limit-chunk-count-plugin stats case to include dependentModules output (and snapshot updates).
  • Add a new statsOutputCases/issue-12572 regression 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.

@github-actions
Copy link
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 1 project with changes.

📊 Quick Summary
Project Total Size Change
react-10k 5.7 MB 0
react-1k 825.4 KB 0
rome 984.2 KB 0
react-5k 2.7 MB 0
ui-components 2.2 MB +1.9 KB (0.1%)
📋 Detailed Reports (Click to expand)

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

📌 Baseline Commit: b28e758882 | PR: #13041

Metric Current Baseline Change
📊 Total Size 2.2 MB 2.2 MB +1.9 KB (0.1%)
📄 JavaScript 2.0 MB 2.0 MB +1.9 KB (0.1%)
🎨 CSS 267.8 KB 267.8 KB 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 0 B 0 B 0

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing 59fd244 to chore: release v2.0.0-beta.2 (#13041) by neverland

❌ Size increased by 640bytes from 48.68MB to 48.68MB (⬆️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 17 untouched benchmarks
⏩ 1 skipped benchmark1


Comparing fix-can-chunks-be-integrated (59fd244) with main (b28e758)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@SyMind SyMind merged commit 3bb764b into main Feb 11, 2026
74 of 76 checks passed
@SyMind SyMind deleted the fix-can-chunks-be-integrated branch February 11, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: OOM Error

2 participants