Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.cpus() undefined on limited shell (TypeError: Cannot read property 'length' of undefined) #19210

Closed
CristianDeluxe opened this issue Mar 7, 2018 · 2 comments
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. os Issues and PRs related to the os subsystem.

Comments

@CristianDeluxe
Copy link

  • Version: 9.7.1
  • Platform: Ubuntu 16.04.4 LTS (x64)
  • Subsystem: VPS

Hi, my hosting is in a virtual machine with ISP config, I access through a limited shell (Jailkit) that has node/npm enabled.

When I try to use a library that checks the number of CPUs, it returns undefined, when in the documentation it says that it should always return an array (even if it is an empty array).

This causes errors with all the modules that use os.cpus(), I verified that they fail with mozjpeg and uglify.

> @ production /web
> cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

/web/node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:54
    this.maxConcurrentWorkers = parallel === true ? _os2.default.cpus().length - 1 : Math.min(Number(parallel) || 0, _os2.default.cpus().length - 1);
                                                                                                                                        ^

TypeError: Cannot read property 'length' of undefined
    at new _class (/web/node_modules/uglifyjs-webpack-plugin/dist/uglify/index.js:54:137)
    at Compilation.<anonymous> (/web/node_modules/uglifyjs-webpack-plugin/dist/index.js:119:24)
    at Compilation.applyPluginsAsyncSeries (/web/node_modules/tapable/lib/Tapable.js:206:13)
    at applyPluginsAsync.err (/web/node_modules/webpack/lib/Compilation.js:663:10)
    at Compilation.applyPluginsAsyncSeries (/web/node_modules/tapable/lib/Tapable.js:195:46)
    at applyPluginsAsyncSeries (/web/node_modules/webpack/lib/Compilation.js:659:9)
    at Compilation.applyPluginsAsyncSeries (/web/node_modules/tapable/lib/Tapable.js:195:46)
    at Compilation.seal (/web/node_modules/webpack/lib/Compilation.js:602:8)
    at applyPluginsParallel.err (/web/node_modules/webpack/lib/Compiler.js:504:17)
    at /web/node_modules/tapable/lib/Tapable.js:289:11
    at _addModuleChain (/web/node_modules/webpack/lib/Compilation.js:505:11)
    at processModuleDependencies.err (/web/node_modules/webpack/lib/Compilation.js:475:14)
    at process._tickCallback (internal/process/next_tick.js:112:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Proposed solution: os.cpus() should return an empty array if it cannot have access to CPU information.

@mscdex
Copy link
Contributor

mscdex commented Mar 7, 2018

Related: #19022

@bnoordhuis
Copy link
Member

Closing as duplicate of #19022. You're welcome to chime in on that issue.

@bnoordhuis bnoordhuis added duplicate Issues and PRs that are duplicates of other issues or PRs. os Issues and PRs related to the os subsystem. labels Mar 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues and PRs that are duplicates of other issues or PRs. os Issues and PRs related to the os subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants