Skip to content

Commit

Permalink
os: add fallback for undefined CPUs
Browse files Browse the repository at this point in the history
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: nodejs#25483
PR-URL: nodejs#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>
  • Loading branch information
JungMinu authored and BridgeAR committed Jan 17, 2019
1 parent 8390014 commit 3bd8e4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function loadavg() {
}

function cpus() {
const data = getCPUs();
// [] is a bugfix for a regression introduced in 51cea61
const data = getCPUs() || [];
const result = [];
for (var i = 0; i < data.length; i += 7) {
result.push({
Expand Down

0 comments on commit 3bd8e4b

Please sign in to comment.