Jest "Worker terminated" - Worker Crashed in CI
A Jest worker process exited abnormally. The most common cause is memory exhaustion under high worker concurrency, though a native crash or an unhandled exception in a worker can also terminate it.
What this error means
A test run fails with "Jest worker encountered N child process exceptions" or a terminated worker. It can be intermittent and worsens as worker count or memory pressure rises.
Jest worker encountered 4 child process exceptions, exceeding retry
limit
at ChildProcessWorker._onExit (.../jest-worker/build/workers/ChildProcessWorker.js:521:23)Common causes
Workers ran out of memory
Too many parallel workers, each holding heavy modules or leaking, exhaust runner RAM and the OS kills a worker.
A native crash or unhandled error in a worker
A segfaulting native addon or an uncaught exception inside a worker terminates the process abnormally.
How to fix it
Reduce worker concurrency and raise heap
Lower maxWorkers and increase the per-process heap so workers do not exhaust memory.
jest --maxWorkers=50% --workerIdleMemoryLimit=512MB
# raise heap if needed
NODE_OPTIONS=--max-old-space-size=4096 jestIsolate the crashing test
Run with --runInBand to find the test that crashes the worker, then fix the leak or native issue.
- Run
jest --runInBandto surface the real stack. - Identify the test or native module that crashes.
- Fix the leak / native incompatibility or quarantine the test.
How to prevent it
- Cap test worker concurrency relative to runner RAM.
- Use a per-worker idle memory limit to recycle leaky workers.
- Quarantine known native-crashing tests until fixed.