os.cpus() failing on lxc containers setting cpuset.cpus to less than the host cpu count #6252
Labels
confirmed-bug
Issues with confirmed bugs.
libuv
Issues and PRs related to the libuv dependency or the uv binding.
When running inside an LXC container with cgroups setup to restrict cpuset.cpus to something less than the number of CPUs in the host machine (very common with cloud providers), accessing os.cpus() will give the following:
To reproduce you will need to run node inside an LXC container with the appropriate cpuset.cpus setting. You can then reproduce with this command:
Because it triggers an assertion failure with an an abort it can't be caught in a try/catch in JavaScript and there really isn't a way to know if it will fail prior to calling it. A common use case for this would be getting the CPU count to use with the cluster module to determine how many instances to run.
While it may not be possible to address the underlying issue it would be helpful it if failed in a way that could be caught in a try/catch so code could be written to use sensible defaults or an alternative method in the event of failure.
The text was updated successfully, but these errors were encountered: