Skip to content
Permalink
Browse files

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: #25483
PR-URL: #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 14, 2019
1 parent 8390014 commit 3bd8e4b6a35aa3347d9442b45947e232e1a97fd4
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/os.js
@@ -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({

0 comments on commit 3bd8e4b

Please sign in to comment.
You can’t perform that action at this time.