diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 24723a3bdd..50166fc79f 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -3709,7 +3709,10 @@ pub const NodeFS = struct { pub fn chown(this: *NodeFS, args: Arguments.Chown, _: Flavor) Maybe(Return.Chown) { if (comptime Environment.isWindows) { - return Syscall.chown(args.path.sliceZ(&this.sync_error_buf), args.uid, args.gid); + return switch (Syscall.chown(args.path.sliceZ(&this.sync_error_buf), args.uid, args.gid)) { + .err => |err| .{ .err = err.withPath(args.path.slice()) }, + .result => |res| .{ .result = res }, + }; } const path = args.path.sliceZ(&this.sync_error_buf); @@ -3721,7 +3724,10 @@ pub const NodeFS = struct { const path = args.path.sliceZ(&this.sync_error_buf); if (comptime Environment.isWindows) { - return Syscall.chmod(path, args.mode); + return switch (Syscall.chmod(path, args.mode)) { + .err => |err| .{ .err = err.withPath(args.path.slice()) }, + .result => |res| .{ .result = res }, + }; } return Maybe(Return.Chmod).errnoSysP(C.chmod(path, args.mode), .chmod, path) orelse @@ -5508,7 +5514,10 @@ pub const NodeFS = struct { } if (comptime Environment.isWindows) { - return Syscall.rmdir(args.path.sliceZ(&this.sync_error_buf)); + return switch (Syscall.rmdir(args.path.sliceZ(&this.sync_error_buf))) { + .err => |err| .{ .err = err.withPath(args.path.slice()) }, + .result => |result| .{ .result = result }, + }; } return Maybe(Return.Rmdir).errnoSysP(system.rmdir(args.path.sliceZ(&this.sync_error_buf)), .rmdir, args.path.slice()) orelse @@ -5769,7 +5778,10 @@ pub const NodeFS = struct { pub fn unlink(this: *NodeFS, args: Arguments.Unlink, _: Flavor) Maybe(Return.Unlink) { if (Environment.isWindows) { - return Syscall.unlink(args.path.sliceZ(&this.sync_error_buf)); + return switch (Syscall.unlink(args.path.sliceZ(&this.sync_error_buf))) { + .err => |err| .{ .err = err.withPath(args.path.slice()) }, + .result => |result| .{ .result = result }, + }; } return Maybe(Return.Unlink).errnoSysP(system.unlink(args.path.sliceZ(&this.sync_error_buf)), .unlink, args.path.slice()) orelse Maybe(Return.Unlink).success; diff --git a/src/js/node/fs.ts b/src/js/node/fs.ts index 6b20a306a1..c8263582e5 100644 --- a/src/js/node/fs.ts +++ b/src/js/node/fs.ts @@ -700,6 +700,9 @@ const realpathSync: any = // This function is ported 1:1 from node.js, to emulate how it is unable to // resolve subst drives to their underlying location. The native call is // able to see through that. + if (typeof p !== "string") { + p += ''; + } p = getValidatedPath(p); throwIfNullBytesInFileName(p); const knownHard = new Set(); @@ -805,6 +808,9 @@ const realpath: any = else encoding = options?.encoding; encoding && (assertEncodingForWindows ?? $newZigFunction("types.zig", "jsAssertEncodingValid", 1))(encoding); } + if (typeof p !== "string") { + p += ''; + } p = getValidatedPath(p); throwIfNullBytesInFileName(p);