summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/node/ops/winerror.rs2
-rw-r--r--tests/unit_node/fs_test.ts11
2 files changed, 12 insertions, 1 deletions
diff --git a/ext/node/ops/winerror.rs b/ext/node/ops/winerror.rs
index e9dbadb6f..cb053774e 100644
--- a/ext/node/ops/winerror.rs
+++ b/ext/node/ops/winerror.rs
@@ -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",
diff --git a/tests/unit_node/fs_test.ts b/tests/unit_node/fs_test.ts
index ac9c4a53e..ef8f829cd 100644
--- a/tests/unit_node/fs_test.ts
+++ b/tests/unit_node/fs_test.ts
@@ -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");
+});