Skip to content

fix: wasm plugin panic when use persistent cache#12455

Merged
jerrykingxyz merged 2 commits intomainfrom
jerry/wasm
Dec 15, 2025
Merged

fix: wasm plugin panic when use persistent cache#12455
jerrykingxyz merged 2 commits intomainfrom
jerry/wasm

Conversation

@jerrykingxyz
Copy link
Copy Markdown
Contributor

@jerrykingxyz jerrykingxyz commented Dec 15, 2025

Summary

  • Remove state from AsyncWasmPlugin to fix persistent cache panic, as persistent caching does not support plugin usage.
  • Removed dashmap and rayon. The number of wasm modules in a single project should be very small, and rayon and dashmap could degrade performance.
  • The wasm filename calculation was moved to render_manifest and was not cached. Considering the small final number of wasm files, this part has little impact on performance.

Related links

Checklist

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

Copilot AI review requested due to automatic review settings December 15, 2025 09:35
@netlify
Copy link
Copy Markdown

netlify bot commented Dec 15, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 41c9869
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/693fda2f53af6000086cae25

@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 15, 2025
@jerrykingxyz jerrykingxyz linked an issue Dec 15, 2025 that may be closed by this pull request
Copy link
Copy Markdown
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 fixes a panic that occurs when using the WASM plugin with persistent cache enabled. The root cause was that AsyncWasmParserAndGenerator contained a non-cacheable field (ModuleIdToFileName, which was a DashMap), making the entire structure incompatible with the caching mechanism. The fix restructures the code to compute WASM module filenames on-demand during the render manifest phase instead of pre-computing and storing them.

Key changes:

  • Removed the ModuleIdToFileName field from AsyncWasmPlugin and AsyncWasmParserAndGenerator, making them cacheable
  • Moved filename generation logic from the generate phase to the render_manifest phase
  • Changed from computing hash via hash_for_source(source) to using the pre-computed build_info().hash

Reviewed changes

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

Show a summary per file
File Description
crates/rspack_plugin_wasm/src/wasm_plugin.rs Removed ModuleIdToFileName field from plugin struct; moved filename generation logic from generator to render_manifest hook; changed from parallel to sequential processing
crates/rspack_plugin_wasm/src/parser_and_generator.rs Removed ModuleIdToFileName field; simplified struct to unit struct; changed to use build_info().hash instead of hash_for_source; removed render_wasm_name helper function; fixed hash string formatting in instantiate call
crates/rspack_plugin_wasm/src/lib.rs Removed ModuleIdToFileName type alias and related imports
crates/rspack_plugin_wasm/Cargo.toml Removed unused dependencies: dashmap, rayon, serde_json
Cargo.lock Updated to reflect removed dependencies from rspack_plugin_wasm

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 15, 2025

📦 Binary Size-limit

Comparing 41c9869 to refactor: extract common utility functions to rspack_util (#12447) by harpsealjs

🎉 Size decreased by 20.75KB from 48.21MB to 48.19MB (⬇️0.04%)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 15, 2025

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-10k

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

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 5.7 MB - -
📄 JavaScript 5.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-1k

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

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 823.6 KB - -
📄 JavaScript 823.6 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-5k

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

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.7 MB - -
📄 JavaScript 2.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 rome

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

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 984.3 KB - -
📄 JavaScript 984.3 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 ui-components

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

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.1 MB - -
📄 JavaScript 2.0 MB - -
🎨 CSS 83.0 KB - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 15, 2025

CodSpeed Performance Report

Merging #12455 will not alter performance

Comparing jerry/wasm (41c9869) with main (1282da9)1

Summary

✅ 17 untouched

Footnotes

  1. No successful run was found on main (6fde634) during the generation of this report, so 1282da9 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@jerrykingxyz jerrykingxyz enabled auto-merge (squash) December 15, 2025 11:01
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]: Rslib cache causes build failure when build again

3 participants