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:
parent
0759cbfc77
commit
2b401e33de
@ -86,7 +86,8 @@ function loadavg() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cpus() {
|
function cpus() {
|
||||||
const data = getCPUs();
|
// [] is a bugfix for a regression introduced in 51cea61
|
||||||
|
const data = getCPUs() || [];
|
||||||
const result = [];
|
const result = [];
|
||||||
for (var i = 0; i < data.length; i += 7) {
|
for (var i = 0; i < data.length; i += 7) {
|
||||||
result.push({
|
result.push({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user