diff --git a/lib/fs.js b/lib/fs.js index 39c00b7db64dee..81c53383357f7f 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -2051,9 +2051,7 @@ function fchownSync(fd, uid, gid) { validateInteger(uid, 'uid', -1, kMaxUserId); validateInteger(gid, 'gid', -1, kMaxUserId); - const ctx = {}; - binding.fchown(fd, uid, gid, undefined, ctx); - handleErrorFromBinding(ctx); + binding.fchown(fd, uid, gid); } /** diff --git a/src/node_file.cc b/src/node_file.cc index 806b1defdaed5d..6ad0391092b3ae 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -2687,17 +2687,15 @@ static void FChown(const FunctionCallbackInfo& args) { CHECK(IsSafeJsInt(args[2])); const uv_gid_t gid = static_cast(args[2].As()->Value()); - FSReqBase* req_wrap_async = GetReqWrap(args, 3); - if (req_wrap_async != nullptr) { // fchown(fd, uid, gid, req) + if (argc > 3) { // fchown(fd, uid, gid, req) + FSReqBase* req_wrap_async = GetReqWrap(args, 3); FS_ASYNC_TRACE_BEGIN0(UV_FS_FCHOWN, req_wrap_async) AsyncCall(env, req_wrap_async, args, "fchown", UTF8, AfterNoArgs, uv_fs_fchown, fd, uid, gid); - } else { // fchown(fd, uid, gid, undefined, ctx) - CHECK_EQ(argc, 5); - FSReqWrapSync req_wrap_sync; + } else { // fchown(fd, uid, gid) + FSReqWrapSync req_wrap_sync("fchown"); FS_SYNC_TRACE_BEGIN(fchown); - SyncCall(env, args[4], &req_wrap_sync, "fchown", - uv_fs_fchown, fd, uid, gid); + SyncCallAndThrowOnError(env, &req_wrap_sync, uv_fs_fchown, fd, uid, gid); FS_SYNC_TRACE_END(fchown); } } diff --git a/typings/internalBinding/fs.d.ts b/typings/internalBinding/fs.d.ts index 5e7b3482bf6260..49b92df05fad24 100644 --- a/typings/internalBinding/fs.d.ts +++ b/typings/internalBinding/fs.d.ts @@ -81,7 +81,7 @@ declare namespace InternalFSBinding { function fchmod(fd: number, mode: number, usePromises: typeof kUsePromises): Promise; function fchown(fd: number, uid: number, gid: number, req: FSReqCallback): void; - function fchown(fd: number, uid: number, gid: number, req: undefined, ctx: FSSyncContext): void; + function fchown(fd: number, uid: number, gid: number): void; function fchown(fd: number, uid: number, gid: number, usePromises: typeof kUsePromises): Promise; function fdatasync(fd: number, req: FSReqCallback): void;