fix: prevent stack overflow in generate_transitive_esm_init on circular dependencies#9041
Merged
shulaoda merged 1 commit intoApr 9, 2026
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
generate_transitive_esm_init on circular dependencies
Merging this PR will not alter performance
Comparing Footnotes
|
@rolldown/browser
@rolldown/debug
@rolldown/pluginutils
rolldown
@rolldown/binding-android-arm64
@rolldown/binding-darwin-arm64
@rolldown/binding-darwin-x64
@rolldown/binding-freebsd-x64
@rolldown/binding-linux-arm-gnueabihf
@rolldown/binding-linux-arm64-gnu
@rolldown/binding-linux-arm64-musl
@rolldown/binding-linux-ppc64-gnu
@rolldown/binding-linux-s390x-gnu
@rolldown/binding-linux-x64-gnu
@rolldown/binding-linux-x64-musl
@rolldown/binding-openharmony-arm64
@rolldown/binding-wasm32-wasi
@rolldown/binding-win32-arm64-msvc
@rolldown/binding-win32-x64-msvc
commit: |
IWANABETHATGUY
approved these changes
Apr 9, 2026
Member
Merge activity
|
Merged
shulaoda
added a commit
that referenced
this pull request
Apr 9, 2026
## [1.0.0-rc.15] - 2026-04-09 ### 🐛 Bug Fixes - prevent stack overflow in `generate_transitive_esm_init` on circular dependencies (#9041) by @shulaoda ### 🚜 Refactor - agents: rename Spec-Driven Development to Context Engineering (#9036) by @hyf0 Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
This was referenced Apr 9, 2026
7 tasks
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.
Summary
generate_transitive_esm_initrecursively traverses module import records to find included importees for ESM init call generation. It has two branches:The visited-set guard (
generated_init_esm_importee_ids) only existed in branch 1. When circular dependencies exist and the involved modules are in different chunks, branch 2 recurses infinitely (A → B → A → B → ...), causing a stack overflow on the rayon worker thread.This was exposed by #8979, which prevents merging common chunks into side-effectful entry chunks — causing more modules to land in separate chunks, making branch 2 far more likely to be hit.
The fix moves the visited-set check before the branch, so it guards both paths.
Fixes #9028
Test plan
issues/9028with circular dependencies in barrel modules understrictExecutionOrder