Skip to content

refactor: remove the encapsulation for rspack_fs::Error #10942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from

Conversation

CPunisher
Copy link
Contributor

@CPunisher CPunisher commented Jul 8, 2025

Summary

rspack_fs::Error contains only std::io::Error for two years. So here considering remove the encapsulation.

There could be some thing wrong with ci linux tools, which produce ~1MB larger artifact than the that in my pc with cross-compilation.

Checklist

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

@CPunisher CPunisher requested a review from LingyuCoder as a code owner July 8, 2025 04:10
Copy link

netlify bot commented Jul 8, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit ec2e044
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/686ccf6adbfb9b00085a80f2

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: refactor labels Jul 8, 2025
@CPunisher CPunisher changed the title refactor: remove the encapsulate rspack_fs::Error refactor: remove the encapsulation for rspack_fs::Error Jul 8, 2025
Copy link
Contributor

github-actions bot commented Jul 8, 2025

📦 Binary Size-limit

Comparing 7e4147c to chore: release v1.4.5 (#10944) by Gengkun

❌ Size increased by 356.80MB from 59.52MB to 416.32MB (⬆️599.48%)

Copy link

codspeed-hq bot commented Jul 8, 2025

CodSpeed Performance Report

Merging #10942 will not alter performance

Comparing 07-07-refactor/remove-rspack-fs-error (ec2e044) with main (a306b03)

Summary

✅ 16 untouched benchmarks

@CPunisher CPunisher force-pushed the 07-07-refactor/remove-rspack-fs-error branch from 10127f0 to cdb7592 Compare July 8, 2025 04:38
@CPunisher CPunisher requested review from Copilot and removed request for LingyuCoder July 8, 2025 04:42
Copy link
Contributor

@Copilot 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 removes the custom rspack_fs::Error wrapper and uses std::io::Error directly, simplifying error handling and aiming to reduce binary size. It updates all filesystem operations to propagate standard I/O errors, replaces to_fs_result conversions with ?, and integrates diagnostic conversions where appropriate.

  • Exposed std::io::Error as the filesystem error type and removed the custom Error enum.
  • Updated all to_fs_result calls to direct ? propagation and added into_diagnostic() for richer error reports.
  • Refactored filesystem implementations (native_fs, memory_fs, intermediate, core utilities) to align with the new error model.

Reviewed Changes

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

Show a summary per file
File Description
packages/rspack-test-tools/package.json Added a test-wasm script for WASM-based tests
crates/rspack_storage/src/fs/error.rs Switched FSError::inner to use std::io::Error directly
crates/rspack_plugin_sri/src/html.rs Added .into_diagnostic() on read_file
crates/rspack_plugin_dll/src/lib_manifest_plugin.rs Wrapped async filesystem calls with .into_diagnostic()
crates/rspack_fs/src/native_fs.rs Removed to_fs_result wrappers; propagate std::io::Error
crates/rspack_fs/src/memory_fs.rs Replaced custom error construction with Error::new
crates/rspack_fs/src/lib.rs Removed export of custom error types; aliased to std::io::Error
crates/rspack_fs/src/intermediate.rs Simplified UTF-8 error return to std::io::Error::other
crates/rspack_fs/src/file_metadata.rs Simplified metadata calls (modified()?, accessed()?)
crates/rspack_fs/src/error.rs Replaced the Error enum with a type alias to std::io::Error
crates/rspack_core/src/utils/fs_trim.rs Changed try_match to return FsResult<bool>
crates/rspack_core/src/resolver/boxfs.rs Simplified ResolverFileSystem error mappings
crates/rspack_core/src/compiler/mod.rs Added .into_diagnostic() around various await calls
Comments suppressed due to low confidence (3)

crates/rspack_fs/src/memory_fs.rs:243

  • [nitpick] The error message is ungrammatical. Consider using "file does not exist" for clarity and proper tense.
      _ => Err(Error::new(ErrorKind::NotFound, "file not exist")),

crates/rspack_fs/src/memory_fs.rs:255

  • [nitpick] This error message could be improved to "file does not exist" to follow standard English usage.
      None => Err(Error::new(ErrorKind::NotFound, "file not exist")),

crates/rspack_fs/src/intermediate.rs:25

  • [nitpick] Consider capitalizing "UTF-8" and refining the message to "invalid UTF-8 line" for clarity.
      Err(_) => Err(std::io::Error::other("invalid utf8 line")),

@@ -80,43 +80,43 @@ impl WritableFileSystem for NativeFileSystem {
impl WritableFileSystem for NativeFileSystem {
Copy link
Preview

Copilot AI Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] There are two identical impl WritableFileSystem for NativeFileSystem blocks in this file. Consider merging them into one implementation to reduce duplication.

Copilot uses AI. Check for mistakes.

@CPunisher CPunisher requested a review from h-a-n-a as a code owner July 8, 2025 04:57
@CPunisher CPunisher marked this pull request as draft July 8, 2025 04:59
@CPunisher CPunisher force-pushed the 07-07-refactor/remove-rspack-fs-error branch from f022f88 to c9804a3 Compare July 8, 2025 07:33
@CPunisher
Copy link
Contributor Author

CPunisher commented Jul 11, 2025

There could be some thing wrong with ci linux tools, which produce ~1MB larger artifact than the that in my pc with cross-compilation. But I have no time to investigate currently.

UPDATE: it seems the ci use GLIBC with newer version

@CPunisher CPunisher closed this Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release: refactor team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant