-
-
Notifications
You must be signed in to change notification settings - Fork 179
fix(uglify/Runner): prevent errors on limited shells where os.cpus
returns undefined
#338
Conversation
src/uglify/Runner.js
Outdated
this.maxConcurrentWorkers = parallel === true ? os.cpus().length - 1 : Math.min(Number(parallel) || 0, os.cpus().length - 1); | ||
// https://github.com/nodejs/node/issues/19022 | ||
// in some cases cpus() returns undefined | ||
const cpusLength = (os.cpus() ? os.cpus().length : 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rewrite to const cpusLength = (os.cpus() || { length: 1 }).length
as said nodejs/node#19022 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I have to make another pull request for this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vielhuber no, let's do here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't know how this is done. Can you help out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vielhuber change code in you branch, commit changes and push with force. Sorry i don't have time to learn, better read book about git
. You can create new PR if you don't know how do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
os.cpus
returns undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on which 'limited shell' your're currently using this plugin (and webpack
). nodejs/node#19022 only seems to mention android
(?). I'm not sure we nor node
itself 'offically' supports that platform. Not blocking on this at all, just curious :)
this.maxConcurrentWorkers = parallel === true ? os.cpus().length - 1 : Math.min(Number(parallel) || 0, os.cpus().length - 1); | ||
// https://github.com/nodejs/node/issues/19022 | ||
// in some cases cpus() returns undefined | ||
const cpusLength = (os.cpus() || { length: 1 }).length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const cpusLength
=> const cpus
(🐦 nitpick)
@michael-ciniawsky some people use |
No description provided.