From 44cd018e08abc9708dbf6e00eb626a30bf79cd65 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Mon, 22 Dec 2025 17:02:29 +0530 Subject: [PATCH] fix: cpu concurrency detection on some platforms `os.availableParallelism()` should produce more accurate results of how much parallelism should be used then `os.cpus().length`. The only breaking change is the newer API requires node versions >= v18.x which is fine as node-gyp only aims to support latest and LTS releases. And the oldest LTS release still supported as of this commit is v22. Fixes #3191 --- lib/build.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/build.js b/lib/build.js index 9c0cca8fc2..00a0abe691 100644 --- a/lib/build.js +++ b/lib/build.js @@ -163,7 +163,7 @@ async function build (gyp, argv) { if (!isNaN(j) && j > 0) { argv.push('/m:' + j) } else if (jobs.toUpperCase() === 'MAX') { - argv.push('/m:' + require('os').cpus().length) + argv.push('/m:' + require('os').availableParallelism()) } } } else { @@ -178,7 +178,7 @@ async function build (gyp, argv) { argv.push(j) } else if (jobs.toUpperCase() === 'MAX') { argv.push('--jobs') - argv.push(require('os').cpus().length) + argv.push(require('os').availableParallelism()) } } }