diff --git a/lib/os.js b/lib/os.js index 81bbe15a9d..b8948633cd 100644 --- a/lib/os.js +++ b/lib/os.js @@ -55,7 +55,7 @@ const { getOSInformation: _getOSInformation, getTotalMem, getUserInfo, - getUptime, + getUptime: _getUptime, isBigEndian, setPriority: _setPriority } = internalBinding('os'); @@ -80,6 +80,8 @@ const { const getHomeDirectory = getCheckedFunction(_getHomeDirectory); const getHostname = getCheckedFunction(_getHostname); const getInterfaceAddresses = getCheckedFunction(_getInterfaceAddresses); +const getUptime = getCheckedFunction(_getUptime); + /** * @returns {string} */ diff --git a/src/node_os.cc b/src/node_os.cc index 046a6106cc..79a50692af 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -149,10 +149,15 @@ static void GetTotalMemory(const FunctionCallbackInfo& args) { static void GetUptime(const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); double uptime; int err = uv_uptime(&uptime); - if (err == 0) - args.GetReturnValue().Set(uptime); + if (err != 0) { + env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_uptime"); + return args.GetReturnValue().SetUndefined(); + } + + args.GetReturnValue().Set(uptime); }