diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-10-23 11:28:04 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-23 11:28:04 +0900 |
commit | 285635daa67274f961d29c1e7795222709dc9618 (patch) | |
tree | 3d7b8a56ee9fb72f740234cc12beaab01e90ccb0 /tests/unit_node/fs_test.ts | |
parent | 5e020ebc3507947cd9e999a4f7213d2d0d5416cf (diff) |
fix(ext/node): map `ERROR_INVALID_NAME` to `ENOENT` on windows (#26475)
In libuv on windows, `ERROR_INVALID_NAME` is mapped to `ENOENT`, but it
is mapped to `EINVAL` in our compat implementation, which causes the
issue #24899.
ref:
https://github.com/libuv/libuv/blob/d4ab6fbba4669935a6bc23645372dfe4ac29ab39/src/win/error.c#L138
closes #24899
closes #26411
closes #23635
closes #21165
closes #19067
Diffstat (limited to 'tests/unit_node/fs_test.ts')
-rw-r--r-- | tests/unit_node/fs_test.ts | 11 |
1 files changed, 11 insertions, 0 deletions
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"); +}); |