Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: add error handling to uv_uptime call #44386

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const {
getOSInformation: _getOSInformation,
getTotalMem,
getUserInfo,
getUptime,
getUptime: _getUptime,
isBigEndian,
setPriority: _setPriority
} = internalBinding('os');
Expand All @@ -80,6 +80,8 @@ const {
const getHomeDirectory = getCheckedFunction(_getHomeDirectory);
const getHostname = getCheckedFunction(_getHostname);
const getInterfaceAddresses = getCheckedFunction(_getInterfaceAddresses);
const getUptime = getCheckedFunction(_getUptime);

/**
* @returns {string}
*/
Expand Down
9 changes: 7 additions & 2 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,15 @@ static void GetTotalMemory(const FunctionCallbackInfo<Value>& args) {


static void GetUptime(const FunctionCallbackInfo<Value>& 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");
addaleax marked this conversation as resolved.
Show resolved Hide resolved
return args.GetReturnValue().SetUndefined();
}

args.GetReturnValue().Set(uptime);
}


Expand Down