-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Assumption that os.cpus() is nonempty - crash #1371
Comments
I wouldn't object to a PR which changed |
Agree on that. It has improved in the last two years - when I first encountered this, code similar to this was failing because length isn't defined on undefined. I'll see if I can make a clean change to fix it and submit a PR. |
Additional comment you will likely need |
Looks like there are other problems - not yet sure what they are. Running
With a first candidate fix for cpus, it's a little better:
Trying to consider if the other errors are significant - I don't think this is the coverage issue you mentioned is present yet. Still looking to determine to see how much effort getting a green test run. |
Okay, after having taken a look at further errors - it appears termux may have additional behavior preventing nyc from fully measuring coverage, in this environment. I'll go ahead and close this issue as it's probably going to be non-trivial for me to fix the full list of errors detected in the nyc unit tests after applying a change for os.cpus. |
running
nyc mocha
from an npm script results in an error where pLimit throws an exception becauseconcurrency
is passed as 0.I've had issues with code using the os.cpus on Termux before (it is a permissions issue deep in node implementation, as I understand it). Behavior right now appears to be to return an empty array instead of unknown (see termux/termux-packages#1798 for example.). This can be demonstrated from within termux console directly:
I manually edited the file, node_modules/nyc/index.js and replaced every use of os.cpus().length with a hard coded 1 value, and this fixed the error I was getting.
This ticket is to request the index.js use of os.cpus() sanitize the value before using it, to guarantee a positive value, as this appears to fix the issue in termux usage.
You can reproduce the behavior I see by mocking or hard coding a value of [] instead of os.cpus() to observe the behavior on any non-trivial package.
Expected Behavior
concurrency assumes 1 if it cannot determine # of cpus because of environmental protections and security (user space Termux app on android device, for example).
Environment Information
Thanks!
The text was updated successfully, but these errors were encountered: