Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

Fix rolldown panic when bundling @aws-sdk/* packages

Root Cause

The panic occurs because symbols in chunk.exports_to_other_chunks lack canonical names. While deconflict_chunk_symbols registers imported symbols with the renamer, it was not registering exported symbols, causing a panic when render_chunk_exports expects canonical names for all exports.

Changes

  • Add exports_to_other_chunks symbols to the renamer in deconflict_chunk_symbols
  • Build and test to verify the fix
  • Run security checks (code review passed)
  • Add regression test for issue [Bug]: Rolldown panics when bundling @aws-sdk/* #6756
  • Update snapshots for CI
  • Rebase onto latest main

Implementation Details

Added code in deconflict_chunk_symbols to iterate over chunk.exports_to_other_chunks keys and add them to the renamer, similar to how imports_from_other_chunks are handled. This ensures all exported symbols have canonical names before rendering.

Test Case

Created test case under crates/rolldown/tests/rolldown/issues/6756/ that demonstrates cross-chunk exports with dynamic imports. The test verifies that symbols exported between chunks receive proper canonical names during deconflicting.

Files Modified

  • crates/rolldown/src/utils/chunk/deconflict_chunk_symbols.rs - Added 6 lines to add exports to renamer
  • crates/rolldown/tests/rolldown/issues/6756/ - Added regression test with fixtures
  • crates/rolldown/tests/snapshots/integration_rolldown__filename_with_hash.snap - Updated snapshot

Security Summary

No security vulnerabilities were introduced. The change follows existing patterns in the codebase and simply ensures that symbols exported to other chunks are properly registered in the renamer, preventing the panic when generating canonical names.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: Rolldown panics when bundling @aws-sdk/*</issue_title>
<issue_description>### Reproduction link or steps

Rolldown panics with a thread panic when attempting to bundle code that uses aws-sdk/*

Here's a minimal repo which reproduces the issue: https://github.com/bishonen/bugs

Alternatively, you can reproduce locally:

git clone [repo]
pnpm install
pnpm run build:broken

What is expected?

The bundle should be created successfully with AWS SDK packages either bundled or marked as external.

What is actually happening?

Rolldown panics with the following error:

thread 'tokio-runtime-worker' panicked at crates/rolldown/src/utils/chunk/render_chunk_exports.rs:108:13:
Canonical name not found for SymbolRef { owner: 715, symbol: SymbolId(14) } in chunk Some("sts") kind: EntryPoint { meta: ChunkMeta(DynamicImported), bit: 16, module: 545 }
for name __Client
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

 ERROR  Error: Panic in async function

The panic occurs specifically when rolldown tries to process the internal structure of @aws-sdk/*. The error indicates that rolldown cannot find a canonical name for a symbol reference related to __Client during chunk rendering.

System Info

System:
    OS: macOS 15.7.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 441.23 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.10.0 - /opt/homebrew/bin/node
    npm: 11.6.0 - /opt/homebrew/bin/npm
    pnpm: 10.15.1 - /opt/homebrew/bin/pnpm
  Browsers:
    Safari: 26.0.1
  npmPackages:
    rolldown: 1.0.0-beta.45 => 1.0.0-beta.45

Any additional comments?

Version 43 does not have this issue.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 30, 2025

How to use the Graphite Merge Queue

Add the label graphite: merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@netlify
Copy link

netlify bot commented Oct 30, 2025

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 7fce220
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69034488c5d03100086424a5
😎 Deploy Preview https://deploy-preview-6765--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Co-authored-by: IWANABETHATGUY <17974631+IWANABETHATGUY@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix rolldown panic when bundling @aws-sdk/* Fix panic when rendering exports to other chunks Oct 30, 2025
Copilot AI requested a review from IWANABETHATGUY October 30, 2025 04:58
@IWANABETHATGUY
Copy link
Member

@copilot try to make a minimum reproduction without any dependency, and use this reproduction to create a test under crates/rolldown/tests/rolldown

Co-authored-by: IWANABETHATGUY <17974631+IWANABETHATGUY@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 30, 2025

@copilot try to make a minimum reproduction without any dependency, and use this reproduction to create a test under crates/rolldown/tests/rolldown

Added a minimal test case at crates/rolldown/tests/rolldown/issues/6756/ that demonstrates cross-chunk exports with dynamic imports. The test uses shared code between statically and dynamically imported modules, creating the scenario where symbols need canonical names in exports_to_other_chunks. Commit: 2543f50

@IWANABETHATGUY
Copy link
Member

@copilot fix CI error

@github-actions
Copy link
Contributor

github-actions bot commented Oct 30, 2025

Benchmarks Rust

  • target: main(c057cbb)
  • pr: copilot/fix-rolldown-panic-aws-sdk(7fce220)
group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     69.5±2.08ms        ? ?/sec    1.01     70.3±2.25ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     75.3±1.45ms        ? ?/sec    1.03     77.5±2.06ms        ? ?/sec
bundle/bundle@rome_ts                                        1.01    111.6±2.93ms        ? ?/sec    1.00    110.5±2.57ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    124.3±2.67ms        ? ?/sec    1.00    124.5±3.54ms        ? ?/sec
bundle/bundle@threejs                                        1.00     41.0±1.65ms        ? ?/sec    1.00     40.8±0.82ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     44.7±1.15ms        ? ?/sec    1.00     44.6±0.69ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    405.0±5.47ms        ? ?/sec    1.00    403.9±6.71ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.01    464.2±5.56ms        ? ?/sec    1.00    461.7±6.06ms        ? ?/sec
scan/scan@rome_ts                                            1.02     88.5±1.70ms        ? ?/sec    1.00     86.6±1.87ms        ? ?/sec
scan/scan@threejs                                            1.04     30.5±1.87ms        ? ?/sec    1.00     29.5±1.31ms        ? ?/sec
scan/scan@threejs10x                                         1.02    307.9±5.01ms        ? ?/sec    1.00    301.6±4.80ms        ? ?/sec

Co-authored-by: IWANABETHATGUY <17974631+IWANABETHATGUY@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 30, 2025

@copilot fix CI error

Fixed CI error by committing the updated snapshot file for test 6756. The snapshot tracks filename hashes and needed to be updated with the corrected test filenames (main.js/dynamic.js instead of entry.js/lib.js). Commit: 68dbb1f

@IWANABETHATGUY IWANABETHATGUY changed the title Fix panic when rendering exports to other chunks fix: panic when rendering exports to other chunks Oct 30, 2025
@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review October 30, 2025 06:30
@IWANABETHATGUY
Copy link
Member

@copilot rebase the pr

Copy link
Contributor Author

Copilot AI commented Oct 30, 2025

@copilot rebase the pr

I've rebased the PR onto the latest origin/main (commit 6f66ef2). The rebase was successful and all tests pass. However, due to tooling constraints (report_progress doesn't support force push), I'm unable to push the rebased commits. The rebased branch is ready locally with commits 668e625c2 (Initial plan), 6367cbf24 (Fix), 6b7efc482 (Add test), and fb0c51a8f (Rebase marker).

To complete the rebase push, you may need to either:

  1. Grant force-push permissions to the automation
  2. Manually force push from your end
  3. Close and reopen the PR with the rebased commits

The rebase resolved a merge conflict in the snapshot file where the new 'duplicate_default_export' test was added between commits.

@IWANABETHATGUY IWANABETHATGUY merged commit ea72de1 into main Oct 31, 2025
28 checks passed
@IWANABETHATGUY IWANABETHATGUY deleted the copilot/fix-rolldown-panic-aws-sdk branch October 31, 2025 04:31
@github-actions github-actions bot mentioned this pull request Nov 3, 2025
shulaoda added a commit that referenced this pull request Nov 3, 2025
## [1.0.0-beta.46] - 2025-11-03

### 💥 BREAKING CHANGES

- default `preserveEntrySignatures` to `'exports-only'` to align with
Rollup (#6723) by @Copilot

### 🚀 Features

- link to docs for commonjs prefer_builtin_feature diagnostic (#6793) by
@sapphi-red
- rolldown_plugin_build_import_analysis: align partial logic (#6789) by
@shulaoda
- improve `EVAL` warning message (#6776) by @sapphi-red
- rolldown: oxc v0.96.0 (#6774) by @Boshen
- rolldown_plugin_build_import_analysis: align partial logic (#6773) by
@shulaoda
- skip `__toESM` when not needed to reduce output size (#6751) by
@Copilot
- improve `EMPTY_IMPORT_META` warning message (#6761) by @sapphi-red
- rolldown_plugin_build_import_analysis: align no preload logic (#6762)
by @shulaoda
- rolldown_plugin_vite_css_post: align `RemovedPureCSSFilesCache` logic
(#6745) by @shulaoda
- rolldown_plugin_build_import_analysis: initialize `generateBundle`
logic (#6744) by @shulaoda
- experimental: introduce `freeExternalMemory` to free external memory
immediately (#6721) by @hyf0

### 🐛 Bug Fixes

- plugins: wrap replacePlugin with makeBuiltinPluginCallable (#6782) by
@huang-julien
- debug: make sure `this.resolve` is also tracked under corresponding
session (#6798) by @hyf0
- legal comments above directives are not preserved (#6787) by @shulaoda
- panic when rendering exports to other chunks (#6765) by @Copilot
- transform/inject: escape special characters in import source (#6778)
by @Copilot
- handle default exports from CJS modules correctly (#6767) by
@IWANABETHATGUY
- rolldown_plugin_build_import_analysis: correct aligned logic (#6768)
by @shulaoda
- duplicate default export when using both import and require (#6764) by
@Copilot
- handle arbitrary module namespace identifiers in
`preserveEntrySignatures: 'allow-extension'` (#6753) by @Copilot
- TypeError when loading CJS files after bundling mixed CJS+TS project
(#6743) by @IWANABETHATGUY
- add warnings for import.meta.dirname/filename/url in UMD and IIFE
formats (#6747) by @Copilot
- rolldown_plugin_manifest: should keep `names` field (#6742) by
@shulaoda
- legal comments above import statements are not preserved (#6717) by
@shulaoda
- remove redundant node check in dynamic entry graph construction
(#6730) by @IWANABETHATGUY

### 🚜 Refactor

- remove unnecessary `#[napi(gettter)]`, use function call directly
(#6694) by @hyf0
- explain the reason if memory doesn't get dropped by
`freeExternalMemory` (#6781) by @hyf0
- pre compute exports (#6755) by @IWANABETHATGUY
- dev: receive an interface for DevRuntime rather than WebSocket
directly (#6734) by @sapphi-red
- dev: fix types for the runtime file and expose it properly (#6731) by
@sapphi-red

### 📚 Documentation

- fix magicstring credit (#6812) by @TheAlexLichter
- in-depth/bundling-cjs: wrap some sections with caveats section (#6796)
by @sapphi-red
- in-depth/bundling-cjs: add "Ambiguous `default` import from CJS
modules" section (#6795) by @sapphi-red
- in-depth/bundling-cjs: make `esmExternalRequirePlugin` link more
prominent (#6792) by @sapphi-red
- add explanation about direct eval (#6775) by @sapphi-red
- add "Non-ESM Output Formats" page (#6760) by @sapphi-red
- use oxc for benchmark comparison in native magic string doc (#6740) by
@sapphi-red
- polish `cleanDir` option (#6741) by @hyf0
- fix image in native magic string doc (#6739) by @sapphi-red
- update description about `attachDebugInfo: 'none'` (#6738) by
@IWANABETHATGUY
- add warning about cleanDir behavior with multiple configs (#6735) by
@Copilot

### 🧪 Testing

- skip paths function test (#6771) by @IWANABETHATGUY
- rust/dev: add test about recover from initial build error (#6567) by
@hyf0

### ⚙️ Miscellaneous Tasks

- correct prepare release binding file (#6817) by @shulaoda
- deps: update github-actions (#6806) by @renovate[bot]
- deps: lock file maintenance npm packages (#6814) by @renovate[bot]
- use correct node version (#6809) by @shulaoda
- deps: lock file maintenance rust crates (#6815) by @renovate[bot]
- deps: update npm packages (major) (#6813) by @renovate[bot]
- deps: update dependency dprint-typescript to v0.95.12 (#6805) by
@renovate[bot]
- fix typo (#6801) by @iiio2
- fix typo in is_import_expr_ignored_by_comment method name (#6797) by
@sapphi-red
- deps: update crate-ci/typos action to v1.39.0 (#6794) by
@renovate[bot]
- deps: upgrade Rust to v1.91.0 and fix new clippy lints (#6785) by
@Copilot
- allow dprint to format `packages/rolldown/tests` except diagnostics
directory (#6772) by @Copilot
- deps: update dependency tsdown to v0.15.12 (#6759) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.17.3 (#6758) by
@renovate[bot]
- test/dev: collect multiple build outputs for each step (#6736) by
@hyf0
- rolldown: change the NAPI-RS binding file to the cjs (#6688) by
@Brooooooklyn
- test: automatically run extra test with `preserve_entry_signatures:
'allow-extension'` (#6727) by @Copilot
- deps: update dependency rolldown-plugin-dts to v0.17.2 (#6732) by
@renovate[bot]
- fix node validation (#6728) by @shulaoda
- deps: lock file maintenance rust crates (#6636) by @renovate[bot]
- deps: update dependency tsdown to v0.15.11 (#6725) by @renovate[bot]

### ❤️ New Contributors

* @huang-julien made their first contribution in
[#6782](#6782)

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Rolldown panics when bundling @aws-sdk/*

3 participants