Skip to content

Commit 96bd2eb

Browse files
authored
fix(task): treat all open errors as NotFound (#40)
https://github.com/oxc-project/oxc/actions/runs/19465327960/job/55698857358 ``` [vite+] run error: [Error: IO error: The filename, directory name, or volume label syntax is incorrect. (os error 123) at AbsolutePath("D:\\a\\oxc\\oxc\\napi/transform/node_modules/node:fs/index.js")] { code: 'GenericFailure' } ```
1 parent 37dfa63 commit 96bd2eb

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

crates/vite_task/src/error.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use std::{ffi::OsString, io, path::Path, sync::Arc};
1+
use std::{ffi::OsString, io, path::Path};
22

33
use fspy::error::SpawnError;
44
use petgraph::algo::Cycle;
55
use vite_path::{
6-
AbsolutePath, RelativePathBuf,
6+
RelativePathBuf,
77
absolute::StripPrefixError,
88
relative::{FromPathError, InvalidPathDataError},
99
};
@@ -54,9 +54,6 @@ pub enum Error {
5454
#[error("The path ({path:?}) is not a valid relative path because: {reason}")]
5555
InvalidRelativePath { path: Box<Path>, reason: FromPathError },
5656

57-
#[error("IO error: {err} at {path:?}")]
58-
IoWithPath { err: io::Error, path: Arc<AbsolutePath> },
59-
6057
#[cfg(unix)]
6158
#[error("Unsupported file type: {0:?}")]
6259
UnsupportedFileType(nix::dir::Type),

crates/vite_task/src/fs.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ fn hash_content(mut stream: impl Read) -> io::Result<u64> {
4040
}
4141

4242
impl FileSystem for RealFileSystem {
43+
#[tracing::instrument(level = "trace")]
4344
fn fingerprint_path(
4445
&self,
4546
path: &Arc<AbsolutePath>,
@@ -49,6 +50,7 @@ impl FileSystem for RealFileSystem {
4950

5051
let file = match File::open(std_path) {
5152
Ok(file) => file,
53+
#[allow(unused)]
5254
Err(err) => {
5355
// On Windows, File::open fails specifically for directories with PermissionDenied
5456
#[cfg(windows)]
@@ -58,18 +60,16 @@ impl FileSystem for RealFileSystem {
5860
return RealFileSystem::process_directory(std_path, path_read);
5961
}
6062
}
61-
62-
return if matches!(
63-
err.kind(),
64-
io::ErrorKind::NotFound |
65-
// A component used as a directory in path is not a directory,
66-
// e.g. "/foo.txt/bar" where "/foo.txt" is a file
67-
io::ErrorKind::NotADirectory
68-
) {
69-
Ok(PathFingerprint::NotFound)
70-
} else {
71-
Err(Error::IoWithPath { err, path: path.clone() })
72-
};
63+
if err.kind() != io::ErrorKind::NotFound {
64+
tracing::trace!(
65+
"Uncommon error when opening {:?} for fingerprinting: {}",
66+
std_path,
67+
err
68+
);
69+
}
70+
// There are many reasons why opening a file might fail (NotFound, InvalidFilename, NotADirectory, PermissionDenied).
71+
// Consider all of them as NotFound for fingerprinting purposes.
72+
return Ok(PathFingerprint::NotFound);
7373
}
7474
};
7575

0 commit comments

Comments
 (0)