diff --git a/lib/fs.js b/lib/fs.js index 56acc657912..da718f3f334 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1161,6 +1161,11 @@ fs.readlinkSync = function(path, options) { options.encoding, undefined, ctx); if (ctx.errno !== undefined) { throw errors.uvException(ctx); + } else if (ctx.error) { + // TODO(joyeecheung): this is an encoding error usually caused by memory + // problems. We need to figure out proper error code(s) for this. + Error.captureStackTrace(ctx.error); + throw ctx.error; } return result; }; @@ -1232,11 +1237,6 @@ fs.symlinkSync = function(target, path, type) { if (ctx.errno !== undefined) { throw errors.uvException(ctx); - } else if (ctx.error) { - // TODO(joyeecheung): this is an encoding error usually caused by memory - // problems. We need to figure out proper error code(s) for this. - Error.captureStackTrace(ctx.error); - throw ctx.error; } }; diff --git a/src/node_file.cc b/src/node_file.cc index a77dc0a9867..62dd5fe80cf 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -886,7 +886,7 @@ static void ReadLink(const FunctionCallbackInfo& args) { fs_req_wrap req; int err = SyncCall(env, args[3], &req, "readlink", uv_fs_readlink, *path); - if (err) { + if (err < 0) { return; // syscall failed, no need to continue, error info is in ctx } const char* link_path = static_cast(req.req.ptr);