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 <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 422a063 commit f4fa04e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎lib/os.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ function loadavg() {
8989
}
9090

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

0 commit comments

Comments
 (0)