-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: create a getter for kernel version #31732
Conversation
lib/os.js
Outdated
getOSType: _getOSType, | ||
getPriority: _getPriority, | ||
getTotalMem, | ||
getUserInfo, | ||
getUptime, | ||
isBigEndian, | ||
getOSVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOSVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review sr!
5b7b562
to
654e9d6
Compare
I've just made a refactor with the internals implementation, we were using |
src/node_os.cc
Outdated
"release", | ||
NewStringType::kNormal).ToLocalChecked(), | ||
release_str) | ||
.FromJust(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nicer to create an Array with 3 entries here, even if that means that means that the order of the entries becomes important:
- It removes the need to create strings for the keys in C++, and
- The
.FromJust()
calls here can be brought to crash if userland code runs before theos
module is required
E.g. the following would current crash the process:
$ node -e 'Object.defineProperty(Object.prototype, "release", { set() { throw new Error(); } }); require("os")'
FATAL ERROR: v8::FromJust Maybe value is Nothing.
1: 0xa15eb0 node::Abort() [./node]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw, here’s a good example of how to create a JS Array from C++ without much overhead:
Lines 100 to 106 in d63bcdd
Local<Value> ret[] = { | |
proxy->GetTarget(), | |
proxy->GetHandler() | |
}; | |
args.GetReturnValue().Set( | |
Array::New(args.GetIsolate(), ret, arraysize(ret))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. the following would current crash the process:
Are these kind of crashes something to be avoided? It can be reproduced with some other properties:
node -e 'Object.defineProperty(Object.prototype, "name", { set() { throw new Error(); } });require("dns").resolveSrv("_jabber._tcp.google.com", () => {});'
FATAL ERROR: v8::FromJust Maybe value is Nothing.
1: 0xa9d570 node::Abort() [node]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@santigimeno Yes – unfortunately, a lot of Node.js core C++ code doesn’t do error handling well, but new code generally should.
654e9d6
to
707bef9
Compare
707bef9
to
bed81ff
Compare
bed81ff
to
1e1bcca
Compare
Is this a |
PR-URL: #31732 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Landed in c1e6725 🎉 |
This does not land cleanly on v13.x. Would someone be willing to open a backport? |
MEEEEEEE ME ME ME ME ME MEEEEEEE, I want to |
Amazing, thanks @juanarbol You can find details on how to do a backport in this guide You wil lwant to target the v13.x-staging branch |
Notable changes: * [[`ff58854dbe`](ff58854dbe)] - **(SEMVER-MINOR)** **fs**: return first folder made by mkdir recursive (Benjamin Coe) [#31530](#31530) * [[`258a80d3cc`](258a80d3cc)] - **(SEMVER-MINOR)** **src**: create a getter for kernel version (Juan José Arboleda) [#31732](#31732) * [[`4d5981be96`](4d5981be96)] - **(SEMVER-MINOR)** **async_hooks**: add sync enterWith to ALS (Stephen Belanger) [#31945](#31945) * [[`dd83bd266d`](dd83bd266d)] - **(SEMVER-MINOR)** **wasi**: add returnOnExit option (Colin Ihrig) [#32101](#32101) PR-URL: #32185
Notable changes: * async_hooks: - add sync enterWith to ALS (Stephen Belanger) #31945 * cli: - allow --jitless V8 flag in NODE\_OPTIONS (Andrew Neitsch) #32100 * fs: - return first folder made by mkdir recursive (Benjamin Coe) #31530 * n-api: - define release 6 (Gabriel Schulhof) #32058 * src: - create a getter for kernel version (Juan José Arboleda) #31732 * wasi: - add returnOnExit option (Colin Ihrig) #32101 PR-URL: #32185
Notable changes: * async_hooks: - add sync enterWith to ALS (Stephen Belanger) #31945 * cli: - allow --jitless V8 flag in NODE\_OPTIONS (Andrew Neitsch) #32100 * fs: - return first folder made by mkdir recursive (Benjamin Coe) #31530 * n-api: - define release 6 (Gabriel Schulhof) #32058 * src: - create a getter for kernel version (Juan José Arboleda) #31732 * wasi: - add returnOnExit option (Colin Ihrig) #32101 PR-URL: #32185
Notable changes: * async_hooks: - add sync enterWith to ALS (Stephen Belanger) #31945 * cli: - allow --jitless V8 flag in NODE\_OPTIONS (Andrew Neitsch) #32100 * fs: - return first folder made by mkdir recursive (Benjamin Coe) #31530 * n-api: - define release 6 (Gabriel Schulhof) #32058 * src: - create a getter for kernel version (Juan José Arboleda) #31732 * wasi: - add returnOnExit option (Colin Ihrig) #32101 PR-URL: #32185
Notable changes: * async_hooks: - add sync enterWith to ALS (Stephen Belanger) #31945 * cli: - allow --jitless V8 flag in NODE\_OPTIONS (Andrew Neitsch) #32100 * fs: - return first folder made by mkdir recursive (Benjamin Coe) #31530 * n-api: - define release 6 (Gabriel Schulhof) #32058 * src: - create a getter for kernel version (Juan José Arboleda) #31732 * wasi: - add returnOnExit option (Colin Ihrig) #32101 PR-URL: #32185
pRtlGetVersion is not a thing. This text was likely a result of copying the variable name used in libuv. This commit updates the documentation to reference the correct Windows API call. PR-URL: nodejs#32156 Refs: nodejs#31732 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Backport-PR-URL: nodejs#32166 PR-URL: nodejs#31732 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes