Skip to content
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

fix(ext/node): map ERROR_INVALID_NAME to ENOENT on windows #26475

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/node/ops/winerror.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn op_node_sys_to_uv_error(err: i32) -> String {
WSAEHOSTUNREACH => "EHOSTUNREACH",
ERROR_INSUFFICIENT_BUFFER => "EINVAL",
ERROR_INVALID_DATA => "EINVAL",
ERROR_INVALID_NAME => "EINVAL",
ERROR_INVALID_NAME => "ENOENT",
ERROR_INVALID_PARAMETER => "EINVAL",
WSAEINVAL => "EINVAL",
WSAEPFNOSUPPORT => "EINVAL",
Expand Down
11 changes: 11 additions & 0 deletions tests/unit_node/fs_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,14 @@ Deno.test("[node/fs] copyFile COPYFILE_EXCL works", async () => {
copyFileSync(src, dest2, fsPromiseConstants.COPYFILE_EXCL)
);
});

Deno.test("[node/fs] statSync throws ENOENT for invalid path containing colon in it", () => {
// deno-lint-ignore no-explicit-any
const err: any = assertThrows(() => {
// Note: Deno.stat throws ERROR_INVALID_NAME (os error 123) instead of
// ERROR_FILE_NOT_FOUND (os error 2) on windows. This case checks that
// ERROR_INVALID_NAME is mapped to ENOENT correctly on node compat layer.
statSync("jsr:@std/assert");
});
assertEquals(err.code, "ENOENT");
});