webpack-contrib / terser-webpack-plugin

Terser Plugin
MIT License
1.94k stars 158 forks source link

fix: ensure that the correct number of CPU cores is obtained within t… #570

Open isbasex opened 1 year ago

isbasex commented 1 year ago

PR Description

Fixes Incorrect CPU Core Count within Docker Container

This PR contains a:

Motivation / Use-Case:

This PR addresses a bug occurring within Docker containers due to an incorrect assumption about the available CPU cores. In the original code, os.cpus().length was used to obtain the number of cores. This works fine in most scenarios, but within a Docker container, this would return the number of cores available to the host system, not the limited number allocated to the container itself. This discrepancy leads to creating an excessive number of concurrent threads, which can ultimately result in an out-of-memory (OOM) error.

This PR corrects this issue by ensuring that the number of cores reported matches the actual number allocated to the Docker container, preventing the creation of too many threads and subsequent OOM errors.

Breaking Changes:

This PR does not introduce any breaking changes.

linux-foundation-easycla[bot] commented 1 year ago

CLA Signed

The committers listed above are authorized under a signed CLA.