Skip to content

fix: pre-resolve paths option to avoid invoke_sync deadlock#8518

Merged
IWANABETHATGUY merged 2 commits intomainfrom
03-02-fix_7280
Mar 2, 2026
Merged

fix: pre-resolve paths option to avoid invoke_sync deadlock#8518
IWANABETHATGUY merged 2 commits intomainfrom
03-02-fix_7280

Conversation

@IWANABETHATGUY
Copy link
Member

@IWANABETHATGUY IWANABETHATGUY commented Mar 2, 2026

closed #7280

Description: Pre-resolves the paths output option asynchronously before entering sync rendering code, eliminating the deadlock-prone invoke_sync pattern that blocks threads waiting for JS callbacks via Mutex + Condvar. Changes PathsFunction to async (matching other options like globals), adds a resolve_all() method, and removes invoke_sync entirely.

Copy link
Member Author


How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready 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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@netlify
Copy link

netlify bot commented Mar 2, 2026

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 889066d
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69a539e6d84d8b0008fafd76
😎 Deploy Preview https://deploy-preview-8518--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.

@netlify
Copy link

netlify bot commented Mar 2, 2026

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit d3a28ad
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69a5560a62e3b70008bba60d
😎 Deploy Preview https://deploy-preview-8518--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.

@IWANABETHATGUY IWANABETHATGUY changed the title fix: 7280 fix: pre-resolve paths option to avoid invoke_sync deadlock Mar 2, 2026
@IWANABETHATGUY IWANABETHATGUY marked this pull request as ready for review March 2, 2026 07:43
Copilot AI review requested due to automatic review settings March 2, 2026 07:43
Copy link
Member Author

IWANABETHATGUY commented Mar 2, 2026

Merge activity

  • Mar 2, 7:43 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 2, 11:25 AM UTC: IWANABETHATGUY added this pull request to the Graphite merge queue.

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

This PR addresses a potential deadlock/hang in the JS binding by removing the synchronous invoke_sync callback path for the output.paths option, and instead pre-resolving paths asynchronously before entering sync rendering code.

Changes:

  • Change PathsFunction to async and introduce PathsOutputOption::resolve_all() to pre-resolve mappings.
  • Remove invoke_sync from JsCallbackExt and update binding normalization to use invoke_async.
  • Thread a pre-resolved resolved_paths through generate/finalize/render paths and use it for external import path rendering.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/rolldown_common/src/inner_bundler_options/types/output_option/paths.rs Makes paths callbacks async-capable and adds async pre-resolution into an FxHashMap.
crates/rolldown_binding/src/utils/normalize_binding_options.rs Switches paths normalization from invoke_sync to invoke_async (boxed future).
crates/rolldown_binding/src/types/js_callback.rs Removes the invoke_sync API to eliminate the deadlock-prone blocking path.
crates/rolldown/src/utils/chunk/mod.rs Uses pre-resolved paths when producing rendered chunk metadata for external imports.
crates/rolldown/src/utils/chunk/finalize_chunks.rs Threads resolved_paths into asset finalization for external import lists.
crates/rolldown/src/types/generator.rs Adds resolved_paths to GenerateContext for sync rendering code.
crates/rolldown/src/stages/generate_stage/render_chunk_to_assets.rs Passes resolved_paths into finalize_assets and generator contexts.
crates/rolldown/src/stages/generate_stage/mod.rs Pre-resolves paths once during generation and stores it on the stage.
crates/rolldown/src/stages/generate_stage/finalize_modules.rs Passes resolved_paths into the scope-hoisting finalizer context.
crates/rolldown/src/module_finalizers/mod.rs Switches external import path computations to use resolved_paths.
crates/rolldown/src/module_finalizers/finalizer_context.rs Extends finalizer context with resolved_paths.
crates/rolldown/src/ecmascript/format/umd.rs Uses resolved_paths for UMD external dependency strings.
crates/rolldown/src/ecmascript/format/esm.rs Uses resolved_paths for ESM external import/export path rendering.
crates/rolldown/src/ecmascript/format/cjs.rs Uses resolved_paths for CJS require(...) path rendering.
Comments suppressed due to low confidence (1)

crates/rolldown_common/src/inner_bundler_options/types/output_option/paths.rs:41

  • In resolve_all, the loop uses id after awaiting f(id), which forces the async state machine to hold a borrowed &str across an .await. Converting id to an owned String before the await (and reusing that for both the callback input and the map key) avoids borrow-across-await and makes this helper more flexible for future call sites.
        let mut resolved = FxHashMap::default();
        for id in ids {
          if let Ok(path) = f(id).await {
            resolved.insert(id.to_string(), path);
          }

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Benchmarks Rust

group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     81.9±2.85ms        ? ?/sec    1.13     92.8±2.54ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     88.2±2.09ms        ? ?/sec    1.10     97.4±2.91ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00    175.9±4.71ms        ? ?/sec    1.07    188.7±3.44ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    185.5±6.27ms        ? ?/sec    1.12    208.2±3.69ms        ? ?/sec
bundle/bundle@threejs                                        1.00     76.7±3.30ms        ? ?/sec    1.12     85.5±3.67ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     86.1±2.10ms        ? ?/sec    1.06     91.5±2.65ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    779.1±8.26ms        ? ?/sec    1.04    807.2±9.41ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00   908.9±15.92ms        ? ?/sec    1.02    924.6±9.83ms        ? ?/sec
scan/scan@rome_ts                                            1.00     85.3±1.75ms        ? ?/sec    1.00     85.2±1.69ms        ? ?/sec
scan/scan@threejs                                            1.00     30.2±1.73ms        ? ?/sec    1.00     30.2±1.69ms        ? ?/sec
scan/scan@threejs10x                                         1.00    285.6±4.51ms        ? ?/sec    1.01    289.1±3.69ms        ? ?/sec

Copy link
Contributor

Copilot AI commented Mar 2, 2026

@IWANABETHATGUY I've opened a new pull request, #8520, to work on those changes. Once the pull request is ready, I'll request review from you.

@IWANABETHATGUY IWANABETHATGUY merged commit a020b5b into main Mar 2, 2026
34 checks passed
@IWANABETHATGUY IWANABETHATGUY deleted the 03-02-fix_7280 branch March 2, 2026 11:25
This was referenced Mar 4, 2026
shulaoda added a commit that referenced this pull request Mar 5, 2026
## [1.0.0-rc.7] - 2026-03-05

⚡ Smarter Code Generation Defaults
- DCE-only minification and smart constant inlining are now enabled by default
- Produces cleaner, smaller output bundles without requiring explicit configuration

💡 LLM-Friendly Bundle Analyzer Reports
- New markdown output format for the bundle analyzer plugin with bundle summaries, module graphs, dependency chains, and optimization suggestions
- Optimization suggestions now also recommend using the entriesAware option when common chunks contain modules only reachable from specific entries


### 💥 BREAKING CHANGES

- enable minify: 'dce-only' by default (#8465) by @IWANABETHATGUY
- settings `inlineConst: { mode: 'smart', pass: 1}`  by default (#8444) by @IWANABETHATGUY

### 🚀 Features

- binding: add original getter to BindingMagicString (#8533) by @IWANABETHATGUY
- native-magic-string: add `offset` property support (#8531) by @IWANABETHATGUY
- add `output.strict` option to control `"use strict"` directive emission (#8489) by @Copilot
- watch: expose `watcher.compareContentsForPolling` (#8526) by @hyf0
- watch: use new watcher to support watch mode (#8475) by @hyf0
- rust/watch: handle bulk-change (#8466) by @hyf0
- add LLM-friendly markdown output format to bundle analyzer plugin (#8242) by @IWANABETHATGUY

### 🐛 Bug Fixes

- expose `plugins` on `NormalizedInputOptions` for `buildStart` hook (#8521) by @Copilot
- only uppercase facade symbols in JSX preserve mode (#8519) by @IWANABETHATGUY
- binding: export BindingResult in generated dts header (#8537) by @minsoo-web
- pre-resolve paths option to avoid `invoke_sync` deadlock (#8518) by @IWANABETHATGUY
- remove debug-only jsx_preset and UntranspiledSyntaxError (#8511) by @IWANABETHATGUY
- apply `topLevelVar` to exported `const`/`let` declarations (#8507) by @IWANABETHATGUY
- rolldown_plugin_vite_web_worker_post: avoid replacing `new.target` (#8488) by @sapphi-red
- update copyright year to 2026 (#8486) by @maciekzygmunt

### 🚜 Refactor

- rust: use Oxc's SymbolFlags::ConstVariable instead of custom IsConst flag (#8543) by @Dunqing
- rust: remove FacadeScoping, use Scoping::create_symbol for facade symbols (#8540) by @Dunqing
- rust/watch: remove hacky `reset_closed_for_watch_mode` (#8530) by @hyf0
- binding: return &str instead of String in filename() getter (#8534) by @IWANABETHATGUY
- rust: remove old watch mode implementation (#8525) by @hyf0
- rust/watch: simply watch logic in the binding layer (#8516) by @hyf0
- rust/watch: tweak struct/function names (#8464) by @hyf0

### 📚 Documentation

- explain how external modules work in rolldown (#8457) by @sapphi-red
- add some diagrams using graphviz (#8499) by @sapphi-red
- use `vitepress-plugin-graphviz` (#8498) by @sapphi-red
- list s390x/ppc64le prebuilt binaries (#8495) by @crusty-voidzero
- fix error type for `RolldownBuild.generate` and others (#8490) by @sapphi-red

### ⚡ Performance

- string_wizard: reduce allocations and add ASCII fast paths (#8541) by @IWANABETHATGUY
- use IndexBitSet to replace IndexVec<XXXIdx, bool> for module/stmt inclusion tracking (#8503) by @IWANABETHATGUY
- plugin: use IndexBitSet to optimize skipped plugins checking (#8497) by @ShroXd
- rust/tla: skip compute_tla if there is no module use TLA (#8487) by @ShroXd

### 🧪 Testing

- node/watch: make watch tests run in concurrent and retry-able (#8512) by @hyf0
- add test case for static flag tree-shaking (#8476) by @IWANABETHATGUY
- migrate post-banner sourcemap-with-shebang to Rust (#8477) by @Copilot

### ⚙️ Miscellaneous Tasks

- vscode: `formatOnSave` for markdown files using oxc formatter (#8536) by @minsoo-web
- deps: update test262 submodule for tests (#8528) by @sapphi-red
- remove `retry` workaround from output paths test fixtures (#8520) by @Copilot
- docs: add Shuyuan Wang (h-a-n-a) and remove from acknowledgements (#8509) by @Copilot
- consolidate top_level_var test cases using configVariants (#8508) by @IWANABETHATGUY
- add s390x and ppc64le linux gnu targets (#8493) by @Brooooooklyn

### ◀️ Revert

- fix(rolldown): increase tokio blocking threads size for watch mode (#8517) by @hyf0

### ❤️ New Contributors

* @minsoo-web made their first contribution in [#8536](#8536)
* @crusty-voidzero made their first contribution in [#8495](#8495)
* @maciekzygmunt made their first contribution in [#8486](#8486)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invoke_sync might cause rolldown hang

4 participants