Node "ERR_WORKER_OUT_OF_MEMORY" in CI
A worker thread exceeded its resource limit (or the runner ran low on memory) and Node terminated it with ERR_WORKER_OUT_OF_MEMORY. Test runners and bundlers that fan out to workers hit this on constrained CI.
What this error means
The run fails with "ERR_WORKER_OUT_OF_MEMORY: Worker terminated due to reaching memory limit". It is intermittent locally but reproducible on small CI runners with many parallel workers.
Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit:
JS heap out of memoryCommon causes
Worker resourceLimits too low
A maxOldGenerationSizeMb on the Worker is smaller than the work it performs.
Too many parallel workers for the runner RAM
A test runner spawns one worker per core; on a small runner the combined heap exceeds available memory.
How to fix it
Reduce worker concurrency
Cap the number of workers so total memory stays within the runner budget.
# vitest
vitest run --poolOptions.threads.maxThreads=2
# jest
jest --maxWorkers=2Raise the worker heap limit
Increase resourceLimits on Workers you control so they have headroom.
new Worker('./task.js', {
resourceLimits: { maxOldGenerationSizeMb: 1024 },
});How to prevent it
- Tune worker concurrency to the runner RAM.
- Set explicit resourceLimits for workers doing heavy work.
- Latchkey self-healing managed runners auto-retry transient OOM-killed worker failures and can provision larger-RAM runners so worker pools do not exhaust memory.