Skip to content

Conversation

@stormslowly
Copy link
Contributor

@stormslowly stormslowly commented Dec 2, 2025

Summary

close #12342

In ContextModule related plugins, filesystem sync APIs are called which is implemented by wrapping async fs API in block_on. And Rspack is running under a block_on already. This will trigger a panic

Solution

Using async api.
And sync fs Api should be forbidden later then?

Related links

Checklist

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

Copilot AI review requested due to automatic review settings December 2, 2025 16:15
@netlify
Copy link

netlify bot commented Dec 2, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit a1a1fed
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/692f13a3f564290008f99943

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Dec 2, 2025
Copilot finished reviewing on behalf of stormslowly December 2, 2025 16: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

This PR converts synchronous filesystem operations to async in the context module resolution pipeline, preventing blocking operations in the tokio runtime. The changes ensure filesystem calls (metadata, read_dir) are properly awaited rather than using their synchronous variants, which aligns with the PR title's goal to "not sync fs api in tokio thread".

Key changes:

  • Converted visit_dirs function to async with recursive directory traversal
  • Changed ResolveContextModuleDependencies type signature from synchronous to async (returning BoxFuture)
  • Updated all resolve_dependencies closures to return Box::pin(async move { ... }) for async execution

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/rspack_core/src/context_module_factory.rs Converted visit_dirs to async with #[async_recursion], changed fs calls from metadata_sync/read_dir_sync to their async equivalents, and wrapped resolve_dependencies closure in async block
crates/rspack_core/src/context_module.rs Updated ResolveContextModuleDependencies type to return BoxFuture and added .await to resolve_dependencies call in build method
crates/rspack_plugin_module_replacement/src/context_replacement.rs Wrapped resolve_dependencies closure in Box::pin(async move { ... }) to match new async signature, added Arc wrapping for captured HashMap

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

📌 Baseline Commit: 5dc9c8976b | PR: #12352

Metric Current Baseline Change
📊 Total Size 822.6 KB 822.6 KB 0 B (0.0%)
📄 JavaScript 822.6 KB 822.6 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-1k Bundle Diff

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

📌 Baseline Commit: 5dc9c8976b | PR: #12352

Metric Current Baseline Change
📊 Total Size 2.7 MB 2.7 MB 0 B (0.0%)
📄 JavaScript 2.7 MB 2.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-5k Bundle Diff

📁 rome

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

📌 Baseline Commit: 5dc9c8976b | PR: #12352

Metric Current Baseline Change
📊 Total Size 984.3 KB 984.3 KB 0 B (0.0%)
📄 JavaScript 984.3 KB 984.3 KB 0 B (0.0%)
🎨 CSS 0 B 0 B N/A
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: rome Bundle Diff

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

📌 Baseline Commit: 5dc9c8976b | PR: #12352

Metric Current Baseline Change
📊 Total Size 5.7 MB 5.7 MB 0 B (0.0%)
📄 JavaScript 5.7 MB 5.7 MB 0 B (0.0%)
🎨 CSS 21.0 B 21.0 B 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: react-10k Bundle Diff

📁 ui-components

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

📌 Baseline Commit: 5dc9c8976b | PR: #12352

Metric Current Baseline Change
📊 Total Size 2.1 MB 2.1 MB 0 B (0.0%)
📄 JavaScript 2.0 MB 2.0 MB 0 B (0.0%)
🎨 CSS 83.0 KB 83.0 KB 0 B (0.0%)
🌐 HTML 0 B 0 B N/A
📁 Other Assets 0 B 0 B N/A

📦 Download Diff Report: ui-components Bundle Diff

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 2, 2025

📦 Binary Size-limit

Comparing a1a1fed to ci: remove legacy ecosystem CI yaml (#12352) by Wei

❌ Size increased by 2.50KB from 47.70MB to 47.71MB (⬆️0.01%)

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 2, 2025

CodSpeed Performance Report

Merging #12353 will not alter performance

Comparing fix/fs_sync_call_2 (a1a1fed) with main (5dc9c89)

Summary

✅ 17 untouched

@stormslowly stormslowly changed the title fix: don't sync fs api in tokio thread fix: don't use sync fs api Dec 2, 2025
@stormslowly stormslowly requested a review from hardfist December 3, 2025 00:25
@stormslowly stormslowly merged commit e5ae2be into main Dec 3, 2025
56 checks passed
@stormslowly stormslowly deleted the fix/fs_sync_call_2 branch December 3, 2025 03:25
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]: useInputFileSystem does not work with dynamic expressions in import()

3 participants