Skip to content
Latchkey

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.

node
Error [ERR_WORKER_OUT_OF_MEMORY]: Worker terminated due to reaching memory limit:
JS heap out of memory

Common 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.

Terminal
# vitest
vitest run --poolOptions.threads.maxThreads=2
# jest
jest --maxWorkers=2

Raise the worker heap limit

Increase resourceLimits on Workers you control so they have headroom.

source
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.

Frequently asked questions

What causes ""ERR_WORKER_OUT_OF_MEMORY""?
A maxOldGenerationSizeMb on the Worker is smaller than the work it performs.
How do I fix "ERR_WORKER_OUT_OF_MEMORY"?
Cap the number of workers so total memory stays within the runner budget.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card