Commit Graph

92 Commits

Author SHA1 Message Date
Yagiz Nizipli
58a8eb4e1c
src: improve node:os userInfo performance
PR-URL: https://github.com/nodejs/node/pull/55719
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2024-11-08 19:40:25 +00:00
Mert Can Altin
81859cf01f
os: improve path check with direct index access
PR-URL: https://github.com/nodejs/node/pull/55434
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
2024-11-02 15:11:44 +00:00
Trivikram Kamat
87e7aeb672
os: use const with early return for path
PR-URL: https://github.com/nodejs/node/pull/54959
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2024-09-18 02:51:46 +00:00
Yagiz Nizipli
1d2603b53f
os: improve tmpdir performance
PR-URL: https://github.com/nodejs/node/pull/54709
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2024-09-11 14:46:30 +00:00
Aras Abbasi
83e6350b82
errors: improve hideStackFrames
PR-URL: https://github.com/nodejs/node/pull/49990
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-11-11 16:25:08 +00:00
Aras Abbasi
0f0dd1a493
os: cache homedir, remove getCheckedFunction
PR-URL: https://github.com/nodejs/node/pull/50037
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-10-15 06:50:31 +00:00
Moshe Atlow
9658d84ddd tools: fix jsdoc lint
PR-URL: https://github.com/nodejs/node/pull/47789
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
2023-05-02 00:48:20 +00:00
Antoine du Hamel
9dbb1623ff
lib: add trailing commas to all public core modules
PR-URL: https://github.com/nodejs/node/pull/46848
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2023-02-28 12:10:24 +01:00
Ruben Bridgewater
f17a642cf2
os: improve network interface performance
This reduces the overhead of getCIDR() to a minimum. No array is
allocated anymore and parts are directly sliced out of the netmask
string instead.

Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: https://github.com/nodejs/node/pull/46598
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-02-20 01:25:54 +00:00
cjihrig
288c421f36
os: add availableParallelism()
This commit exposes uv_available_parallelism() as an alternative
to cpus().length. uv_available_parallelism() is inspired by
Rust's available_parallelism().

PR-URL: https://github.com/nodejs/node/pull/45895
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2022-12-21 16:53:24 -05:00
Luigi Pinca
58431c0e6b os: convert uid and gid to 32-bit signed integers
Make `os.userInfo()` convert the `uid` and `gid` fields to 32-bit signed
integers on Windows.

PR-URL: https://github.com/nodejs/node/pull/42340
Refs: https://github.com/libuv/libuv/commit/f3e0bffcb14
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-11-05 19:52:50 +01:00
Juan José Arboleda
7ee8bfe1cd src: add error handling to uv_uptime call
PR-URL: https://github.com/nodejs/node/pull/44386
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-31 14:28:28 -05:00
theanarkh
d40a622016
os: add machine method
PR-URL: https://github.com/nodejs/node/pull/44416
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-08-29 07:49:32 +00:00
Antoine du Hamel
70b516e4db dns: accept 'IPv4' and 'IPv6' for family
Refs: https://github.com/nodejs/node/issues/43014

PR-URL: https://github.com/nodejs/node/pull/43054
Fixes: https://github.com/nodejs/node/issues/43014
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2022-06-15 18:02:01 -04:00
Antoine du Hamel
06d8606960
lib: use null-prototype objects for property descriptors
Refs: https://github.com/nodejs/node/pull/42921

PR-URL: https://github.com/nodejs/node/pull/43270
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
2022-06-03 09:23:58 +01:00
Himself65
d62e41262b
typings: fix os.cpus invalid return type
PR-URL: https://github.com/nodejs/node/pull/43006
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
2022-05-11 00:52:19 +02:00
Antoine du Hamel
3a26db9697 net: make server.address() return an integer for family
`dns.lookup` options only accepts integer for `family` options,
having a string doesn't really make sense here.

PR-URL: https://github.com/nodejs/node/pull/41431
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2022-04-12 05:50:09 +02:00
Mohammed Keyvanzadeh
b5f0b49b9b
os: avoid unnecessary usage of var
The `var` keyword is known to be problematic and is not needed here,
so better to use the `let` keyword for variable declarations.

PR-URL: https://github.com/nodejs/node/pull/42563
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-04-03 16:36:55 +01:00
Luigi Pinca
152d675cc6 os: add os.devNull
Provides the platform-specific file path of the null device.

PR-URL: https://github.com/nodejs/node/pull/38569
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2021-06-01 21:06:18 +02:00
Akhil Marsonya
00b6feec3e
lib: fix and improve os typings
1. marked optional params as such
2. assigned default values using jsdoc conventions.

PR-URL: https://github.com/nodejs/node/pull/38316
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2021-04-26 11:54:15 -07:00
David Brownman
d97787fccc
typings: add JSDoc to os module functions
PR-URL: https://github.com/nodejs/node/pull/38197
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2021-04-18 11:04:20 +02:00
Antoine du Hamel
f34d8de65a lib: remove use of array destructuring
PR-URL: https://github.com/nodejs/node/pull/36818
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-03-03 19:53:24 +01:00
Rich Trott
b461a1b125 doc,lib: prepare for stricter multi-line array linting
We're about to turn on a requirement for dangling commas.

PR-URL: https://github.com/nodejs/node/pull/37088
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2021-02-19 09:55:35 -08:00
Antoine du Hamel
e6e708400b os: refactor to use more primordials
PR-URL: https://github.com/nodejs/node/pull/36284
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-12-01 14:27:43 +00:00
Michaël Zasso
a073f532da lib: use Number.parseInt from primordials
PR-URL: https://github.com/nodejs/node/pull/35499
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Shingo Inoue <leko.noor@gmail.com>
2020-10-07 13:44:20 +00:00
Sebastien Ahkrin
34b7b47849
lib: replace Float64Array global with primordials
PR-URL: https://github.com/nodejs/node/pull/35397
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Pranshu Srivastava <rexagod@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
2020-10-04 09:40:51 +02:00
Juan José Arboleda
c1e672595f
src: create a getter for kernel version
PR-URL: https://github.com/nodejs/node/pull/31732
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-03-09 12:44:16 +01:00
James M Snell
ab4115f17c
os: move tmpDir() to EOL
The tmpDir alias was deprecated in 7.0.0

PR-URL: https://github.com/nodejs/node/pull/31169
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-02-05 17:50:42 -08:00
Sebastien Ahkrin
e490b2ca90 lib: replace Symbol.toPrimitive to SymbolToPrimitive primordials
PR-URL: https://github.com/nodejs/node/pull/30905
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-13 20:05:49 -05:00
Sebastien Ahkrin
eac3f0adc4
lib: replace Symbol global by the primordials Symbol
PR-URL: https://github.com/nodejs/node/pull/30737
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-12-08 13:38:58 +01:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.

PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-25 10:28:15 +01:00
Michaël Zasso
908292cf1f lib: enforce the use of Object from primordials
PR-URL: https://github.com/nodejs/node/pull/27146
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2019-04-12 05:38:45 +02:00
Ruben Bridgewater
bfbce289c3
lib: refactor Error.captureStackTrace() usage
When using `Errors.captureStackFrames` the error's stack property
is set again. This adds a helper function that wraps this functionality
in a simple API that does not only set the stack including the `code`
property but it also improves the performance to create the error.
The helper works for thrown errors and errors returned from wrapped
functions in case they are Node.js core errors.

PR-URL: https://github.com/nodejs/node/pull/26738
Fixes: https://github.com/nodejs/node/issues/26669
Fixes: https://github.com/nodejs/node/issues/20253
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-03-23 02:55:54 +01:00
Gireesh Punathil
e51da1fcad src: simplify loop arithmetic in GetCPUInfo
Cache the repeated operations and reuse; potentially generating
efficient code in some platforms, and improving readability.

PR-URL: https://github.com/nodejs/node/pull/26183
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-21 08:45:40 +01:00
Minwoo Jung
2b401e33de os: add fallback for undefined CPUs
For an unsupported OS, a call to os.cpus() throws an error
within os.cpus() itself where it tries to get the length of it.
This fixes the issue by adding fallback for undefined CPUs.

Fixes: https://github.com/nodejs/node/issues/25483
PR-URL: https://github.com/nodejs/node/pull/25493
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-16 12:41:56 +09:00
Brian White
5021b259ed os: improve networkInterfaces() performance
PR-URL: https://github.com/nodejs/node/pull/25410
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-01-14 07:42:27 +01:00
cjihrig
853bee0acf
lib: move DEP0023 to end of life
This commit moves DEP0023 to end of life status. The
os.getNetworkInterfaces() method was introduced in the
unstable 0.5.0 release, and runtime deprecated in 0.6.0, the
first stable release of its existence.

This commit also fixes an inaccuracy in the deprecation, as the
replacement (os.networkInterfaces()) is actually a method.

PR-URL: https://github.com/nodejs/node/pull/25280
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-01-06 11:50:19 -05:00
briete
937c7695aa os: move process.binding('os') to internalBinding
PR-URL: https://github.com/nodejs/node/pull/25087
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-20 05:29:16 +01:00
Joyee Cheung
321e296371
process: move POSIX credential accessors into node_credentials.cc
Expose the POSIX credential accessors through
`internalBinding('credentials')` instead of setting them on the
process or bootstrapper object from C++ directly. Also moves
`SafeGetEnv` from `internalBinding('util')` to
`internalBinding('credentials')` since it's closely related to
the credentials.

In the JS land, instead of wrapping the bindings then writing
to the process object directly in main_thread_only.js, return
the wrapped functions back to bootstrap/node.js where they get
written to the process object conditionally for clarity.

Refs: https://github.com/nodejs/node/issues/24961

PR-URL: https://github.com/nodejs/node/pull/25066
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-12-19 02:44:03 +08:00
Joyee Cheung
51cea618e2
os: do not call into JS to push values to an array in GetCPUInfo
Instead of calling into JS from C++ to push values into an array,
use the new Array::New API that takes a pointer and a length
directly.

PR-URL: https://github.com/nodejs/node/pull/24264
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-11-14 02:59:45 +08:00
Anna Henningsen
87b808f761
src,lib: move natives and constants to internalBinding()
Refs: https://github.com/nodejs/node/issues/22160

PR-URL: https://github.com/nodejs/node/pull/23663
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-10-21 03:17:12 +02:00
Gus Caplan
e7f710c1d4 bootstrapper: move internalBinding to NativeModule
internalBinding is used so often that it should just automatically be
available for usage in internals.

PR-URL: https://github.com/nodejs/node/pull/23025
Refs: https://github.com/nodejs/node/commit/2a9eb31
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-10-04 11:55:34 +02:00
cjihrig
7e4b0a4850
util: make util binding internal
Refs: https://github.com/nodejs/node/issues/22160
PR-URL: https://github.com/nodejs/node/pull/22675
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-09-05 21:53:11 -04:00
cjihrig
e2b033ebc3
os: don't use getCheckedFunction() in userInfo()
os.userInfo() takes an optional object as its first argument.
getCheckedFunction() adds a context object to the argument list
passed to the binding layer. The context object has the potential
to confuse the binding layer, particularly if an error occurs.
This commit makes userInfo() explicitly call into the binding
layer with two arguments.

PR-URL: https://github.com/nodejs/node/pull/22609
Refs: https://github.com/nodejs/node/pull/22599
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-09-03 09:36:54 -04:00
cjihrig
92880f31da
os: add os.{get,set}Priority()
PR-URL: https://github.com/nodejs/node/pull/22407
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2018-08-22 17:27:16 -04:00
cjihrig
5e420f95b1
os: destructure ERR_SYSTEM_ERROR properly
PR-URL: https://github.com/nodejs/node/pull/22394
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-08-20 11:33:02 -04:00
Ruben Bridgewater
9bcb744ee5
os: improve networkInterfaces performance
This algorithm uses less data transformations and is therefore
significantly faster than the one before.

PR-URL: https://github.com/nodejs/node/pull/22359
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-08-20 16:10:20 +02:00
Daniel Bevenius
f31fc9398d
lib: remove unnecessary assignment of exports
This commit removes the assignment of exports since it is not used
in these files and there is no harm re-assigning module.exports.

PR-URL: https://github.com/nodejs/node/pull/20143
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2018-04-22 11:39:16 +02:00
Joyee Cheung
7d06761f83
errors: improve SystemError messages
This commit improves the SystemError messages by allowing user
to combine a custom message and the libuv error message. Also
since we now prefer use subclasses to construct the errors instead
of using `new errors.SystemError()` directly, this removes
the behavior of assigning a default error code `ERR_SYSTEM_ERROR`
to SystemError and requires the user to directly use the
`ERR_SYSTEM_ERROR` class to construct errors instead.

Also merges `makeNodeError` into the SystemError class definition
since that's the only place the function gets used and it seems
unnecessary to introduce another level of inheritance. SystemError
now directly inherits from Error instead of an intermmediate Error
class that inherits from Error.

Class hierarchy before this patch:

ERR_SOCKET_BUFFER_SIZE -> Error (use message formatted by SystemError)
ERR_SYSTEM_ERROR -> NodeError (temp) -> Error

After:

ERR_SOCKET_BUFFER_SIZE -> SystemError -> Error
ERR_TTY_INIT_FAILED -> SystemError -> Error
ERR_SYSTEM_ERROR -> SystemError -> Error

Error messages before this patch:

```
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');
socket.setRecvBufferSize(8192);

// Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer
// size: Error [ERR_SYSTEM_ERROR]: bad file descriptor:
// EBADF [uv_recv_buffer_size]
//    at bufferSize (dgram.js:191:11)
//    at Socket.setRecvBufferSize (dgram.js:689:3)

const tty = require('tty');
new tty.WriteStream(1 << 30);
// Error [ERR_SYSTEM_ERROR]: invalid argument: EINVAL [uv_tty_init]
//     at new WriteStream (tty.js:84:11)
```

After:

```
const dgram = require('dgram');
const socket = dgram.createSocket('udp4');
socket.setRecvBufferSize(8192);

// SystemError [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer
// size: uv_recv_buffer_size returned EBADF (bad file descriptor)
//     at bufferSize (dgram.js:191:11)
//     at Socket.setRecvBufferSize (dgram.js:689:3)

const tty = require('tty');
new tty.WriteStream(1 << 30);
// SystemError [ERR_TTY_INIT_FAILED]: TTY initialization failed:
// uv_tty_init returned EINVAL (invalid argument)
//     at new WriteStream (tty.js:84:11)
```

PR-URL: https://github.com/nodejs/node/pull/19514
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2018-04-05 04:46:26 +08:00
Jose M. Palacios Diaz
916cfeca77
lib,src: audit process.env in lib/ for setuid binary
Wrap SafeGetenv() in util binding with the purpose of protecting
the cases when env vars are accessed with the privileges of another
user in jsland.

PR-URL: https://github.com/nodejs/node/pull/18511
Fixes: https://github.com/nodejs/node/issues/9160
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2018-02-16 17:42:21 +01:00