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: #25483
PR-URL: #25493
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • 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.