Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Commit 6d9c36f

Browse files
evilebottnawimichael-ciniawsky
authored andcommitted
fix(uglify/Runner): cpus length in a chroot environment (os.cpus()) (#341)
1 parent c67566e commit 6d9c36f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/uglify/Runner.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export default class Runner {
1616
constructor(options = {}) {
1717
const { cache, parallel } = options;
1818
this.cacheDir = cache === true ? findCacheDir({ name: 'uglifyjs-webpack-plugin' }) : cache;
19-
this.maxConcurrentWorkers = parallel === true ? os.cpus().length - 1 : Math.min(Number(parallel) || 0, os.cpus().length - 1);
19+
// In some cases cpus() returns undefined
20+
// https://github.com/nodejs/node/issues/19022
21+
const cpus = (os.cpus() || { length: 1 });
22+
this.maxConcurrentWorkers = parallel === true ? cpus.length - 1 : Math.min(Number(parallel) || 0, cpus.length - 1);
2023
}
2124

2225
runTasks(tasks, callback) {

0 commit comments

Comments
 (0)