From 13f37b6e2001bc185ceeea67a84d9279af61f17d Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 19 Nov 2025 11:21:28 +0800 Subject: [PATCH 1/3] fix(task): treat all open errors as NotFound --- crates/vite_task/src/error.rs | 7 ++----- crates/vite_task/src/fs.rs | 15 ++++----------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/crates/vite_task/src/error.rs b/crates/vite_task/src/error.rs index 1aba67eb..7ea49bcd 100644 --- a/crates/vite_task/src/error.rs +++ b/crates/vite_task/src/error.rs @@ -1,9 +1,9 @@ -use std::{ffi::OsString, io, path::Path, sync::Arc}; +use std::{ffi::OsString, io, path::Path}; use fspy::error::SpawnError; use petgraph::algo::Cycle; use vite_path::{ - AbsolutePath, RelativePathBuf, + RelativePathBuf, absolute::StripPrefixError, relative::{FromPathError, InvalidPathDataError}, }; @@ -54,9 +54,6 @@ pub enum Error { #[error("The path ({path:?}) is not a valid relative path because: {reason}")] InvalidRelativePath { path: Box, reason: FromPathError }, - #[error("IO error: {err} at {path:?}")] - IoWithPath { err: io::Error, path: Arc }, - #[cfg(unix)] #[error("Unsupported file type: {0:?}")] UnsupportedFileType(nix::dir::Type), diff --git a/crates/vite_task/src/fs.rs b/crates/vite_task/src/fs.rs index e332a520..bdc9217f 100644 --- a/crates/vite_task/src/fs.rs +++ b/crates/vite_task/src/fs.rs @@ -49,6 +49,7 @@ impl FileSystem for RealFileSystem { let file = match File::open(std_path) { Ok(file) => file, + #[allow(unused)] Err(err) => { // On Windows, File::open fails specifically for directories with PermissionDenied #[cfg(windows)] @@ -59,17 +60,9 @@ impl FileSystem for RealFileSystem { } } - return if matches!( - err.kind(), - io::ErrorKind::NotFound | - // A component used as a directory in path is not a directory, - // e.g. "/foo.txt/bar" where "/foo.txt" is a file - io::ErrorKind::NotADirectory - ) { - Ok(PathFingerprint::NotFound) - } else { - Err(Error::IoWithPath { err, path: path.clone() }) - }; + // There are many reasons why opening a file might fail (NotFound, InvalidFilename, NotADirectory, PermissionDenied). + // Consider all of them as NotFound for fingerprinting purposes. + return Ok(PathFingerprint::NotFound); } }; From 52032b3b2b107ebec835cad16e55764b4dae8f8b Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 19 Nov 2025 12:36:35 +0800 Subject: [PATCH 2/3] add tracing code --- crates/vite_task/src/fs.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/vite_task/src/fs.rs b/crates/vite_task/src/fs.rs index bdc9217f..6d83fe9b 100644 --- a/crates/vite_task/src/fs.rs +++ b/crates/vite_task/src/fs.rs @@ -40,6 +40,7 @@ fn hash_content(mut stream: impl Read) -> io::Result { } impl FileSystem for RealFileSystem { + #[tracing::instrument(level = "trace")] fn fingerprint_path( &self, path: &Arc, @@ -59,7 +60,13 @@ impl FileSystem for RealFileSystem { return RealFileSystem::process_directory(std_path, path_read); } } - + if err.kind() != io::ErrorKind::NotFound { + tracing::trace!( + "Uncommon error when openning {:?} for fingerprinting: {}", + std_path, + err + ); + } // There are many reasons why opening a file might fail (NotFound, InvalidFilename, NotADirectory, PermissionDenied). // Consider all of them as NotFound for fingerprinting purposes. return Ok(PathFingerprint::NotFound); From 388f87b7350db286a7dfbbbab3e9ce87b1f36811 Mon Sep 17 00:00:00 2001 From: branchseer Date: Wed, 19 Nov 2025 12:40:55 +0800 Subject: [PATCH 3/3] fix typo --- crates/vite_task/src/fs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vite_task/src/fs.rs b/crates/vite_task/src/fs.rs index 6d83fe9b..b47ba81a 100644 --- a/crates/vite_task/src/fs.rs +++ b/crates/vite_task/src/fs.rs @@ -62,7 +62,7 @@ impl FileSystem for RealFileSystem { } if err.kind() != io::ErrorKind::NotFound { tracing::trace!( - "Uncommon error when openning {:?} for fingerprinting: {}", + "Uncommon error when opening {:?} for fingerprinting: {}", std_path, err );