0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

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>
This commit is contained in:
Minwoo Jung 2019-01-14 23:02:48 +09:00
parent 0759cbfc77
commit 2b401e33de

View File

@ -86,7 +86,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({