Skip to content

Commit 3bd8e4b

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 <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>
1 parent 8390014 commit 3bd8e4b

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)