Skip to content

Commit f4fa04e

Browse files
JungMinuBridgeAR
authored andcommitted
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 <[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]>
1 parent 422a063 commit f4fa04e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/os.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ function loadavg() {
8989
}
9090

9191
function cpus() {
92-
const data = getCPUs();
92+
// [] is a bugfix for a regression introduced in 51cea61
93+
const data = getCPUs() || [];
9394
const result = [];
9495
for (var i = 0; i < data.length; i += 7) {
9596
result.push({

0 commit comments

Comments
 (0)