NodeJS Builds or Test Suites Fail With ENOMEM or a Timeout

Workers/Threads Exceed Available Memory

A common issue with running NodeJS test suites that spawn workers/threads in a Docker container is that these scripts will spawn too many workers/threads and cause excessive memory usage. In most cases this will cause jobs to fail with ENOMEM errors.

This happens because the script looks at the number of CPUs available on the physical machine, which can be 32+ cores, rather than the number vCPUs the Docker container has been allocated.

The number of workers/threads your test suites uses will need to be configured to not exceed the number of vCPUs allocated to the resource class in use (medium by default).

For example, if using Jest, set the maxWorkers option:

--maxWorkers=2

 

Additional Resources

Was this article helpful?
23 out of 34 found this helpful

Comments

0 comments

Article is closed for comments.