From 6e8a099e72e4005e75b45e409c69423c80d8f4e7 Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Fri, 17 Jan 2025 20:34:47 -0800 Subject: [PATCH] more oops --- src/bun.js/node/node_fs.zig | 9 ++++++--- test/js/node/watch/fs.watch.test.ts | 10 +++++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/bun.js/node/node_fs.zig b/src/bun.js/node/node_fs.zig index 58ae976716..52a99a9494 100644 --- a/src/bun.js/node/node_fs.zig +++ b/src/bun.js/node/node_fs.zig @@ -2542,10 +2542,13 @@ pub const Arguments = struct { if (arguments.next()) |arg_position| { arguments.eat(); - const num: i64 = try JSC.Node.validators.validateIntegerOrBigInt(ctx, arg_position, "position", -1, 9007199254740991); - if (num >= 0) - args.position = @as(ReadPosition, @intCast(num)); + if (!arg_position.isNull()) { + const num: i64 = try JSC.Node.validators.validateIntegerOrBigInt(ctx, arg_position, "position", -1, 9007199254740991); + + if (num >= 0) + args.position = @as(ReadPosition, @intCast(num)); + } } } else if (current.isObject()) { if (try current.getTruthy(ctx, "offset")) |num| { diff --git a/test/js/node/watch/fs.watch.test.ts b/test/js/node/watch/fs.watch.test.ts index d599ef3c0a..56b115febc 100644 --- a/test/js/node/watch/fs.watch.test.ts +++ b/test/js/node/watch/fs.watch.test.ts @@ -259,7 +259,7 @@ describe("fs.watch", () => { } catch (err: any) { expect(err).toBeInstanceOf(Error); expect(err.code).toBe("ENOENT"); - expect(err.syscall).toBe("open"); + expect(err.syscall).toBe("watch"); done(); } }); @@ -447,10 +447,10 @@ describe("fs.watch", () => { watcher.close(); expect.unreachable(); } catch (err: any) { - expect(err.message).toBe(`EACCES: permission denied, open '${filepath}'`); + expect(err.message).toBe(`EACCES: permission denied, watch '${filepath}'`); expect(err.path).toBe(filepath); expect(err.code).toBe("EACCES"); - expect(err.syscall).toBe("open"); + expect(err.syscall).toBe("watch"); } }); @@ -464,10 +464,10 @@ describe("fs.watch", () => { watcher.close(); expect.unreachable(); } catch (err: any) { - expect(err.message).toBe(`EACCES: permission denied, open '${filepath}'`); + expect(err.message).toBe(`EACCES: permission denied, watch '${filepath}'`); expect(err.path).toBe(filepath); expect(err.code).toBe("EACCES"); - expect(err.syscall).toBe("open"); + expect(err.syscall).toBe("watch"); } }); });