diff --git a/lib/internal/fs/read/utf8.js b/lib/internal/fs/read/utf8.js index e916c918c11190..5159db5988ee0b 100644 --- a/lib/internal/fs/read/utf8.js +++ b/lib/internal/fs/read/utf8.js @@ -16,7 +16,8 @@ function readFileSyncUtf8(path, flag) { return response; } - handleErrorFromBinding({ errno: response, path }); + const { 0: errno, 1: syscall } = response; + handleErrorFromBinding({ errno, syscall, path }); } module.exports = { diff --git a/src/node_file.cc b/src/node_file.cc index 4106918512e93c..eb1c9b8dd90dcf 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1961,6 +1961,7 @@ static inline Maybe CheckOpenPermissions(Environment* env, static void ReadFileSync(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); + auto isolate = env->isolate(); CHECK_GE(args.Length(), 2); @@ -1980,8 +1981,11 @@ static void ReadFileSync(const FunctionCallbackInfo& args) { FS_SYNC_TRACE_END(open); if (req.result < 0) { // req will be cleaned up by scope leave. - return args.GetReturnValue().Set( - v8::Integer::New(env->isolate(), req.result)); + Local out[] = { + Integer::New(isolate, req.result), // errno + FIXED_ONE_BYTE_STRING(isolate, "open"), // syscall + }; + return args.GetReturnValue().Set(Array::New(isolate, out, arraysize(out))); } uv_fs_req_cleanup(&req); @@ -2001,8 +2005,12 @@ static void ReadFileSync(const FunctionCallbackInfo& args) { if (req.result < 0) { FS_SYNC_TRACE_END(read); // req will be cleaned up by scope leave. + Local out[] = { + Integer::New(isolate, req.result), // errno + FIXED_ONE_BYTE_STRING(isolate, "read"), // syscall + }; return args.GetReturnValue().Set( - v8::Integer::New(env->isolate(), req.result)); + Array::New(isolate, out, arraysize(out))); } uv_fs_req_cleanup(&req); if (r <= 0) {