A jest worker process was terminated by another process
Asked Answered
N

3

28

I am getting following error when I am building my application.

Test suite failed to run

  A jest worker process (pid=2439) was terminated by another process: signal=SIGKILL, exitCode=null. Operating system logs may contain more information on why this occurred.
    at ChildProcessWorker._onExit (node_modules/jest-worker/build/workers/ChildProcessWorker.js:366:23)

Can you please advice how to check OS logs on linux system and how to resolve this issue?

Neuromuscular answered 8/5, 2023 at 18:40 Comment(1)
I'm getting this error in my Jenkins pipeline and not in local. Does anyone know what is the root cause for this issue? – Asthma
H
17

A temporary workaround is running jest with these two arguments, --runInBand --no-cache, to run all tests in serial (slower) and to use a clean cache every time (also slower). But at least the tests run. 😬

FYI, I'm using NODE_OPTIONS=--experimental-vm-modules to use ESM modules with ts-jest. Not sure if that causes the instability.

Havelock answered 23/7, 2023 at 22:58 Comment(1)
` --runInBand` solves the issue, no need for --no-cache, also --experimental-vm-modules is not needed unless u need to work with ESM – Semple
M
3

Should be resolved by https://github.com/jestjs/jest/pull/14015 Please update version of jest to latest and issue should be resolved.

Update: If not working we found a workaround of adding and extra jest worker. Refer to documentation: https://jestjs.io/docs/configuration#maxworkers-number--string

Michamichael answered 26/6, 2023 at 8:48 Comment(4)
Sadly, it doesn't solve the problem for us. Even with Jest 29.6.1 (the "fix" has been released in 29.6.0) – Leucas
Apologies. We resolved the issue by adding an extra worker. – Michamichael
This is a workaround in the jest configuration file jestjs.io/docs/configuration#maxworkers-number--string – Michamichael
I don't see any difference. I set maxWorkers to 50% because that's the trial and error best value I could find to optimize for speed, but I still get many SIGKILL errors when the machine is under stress, which happens whenever I open more than one VSCode window. My script is "test": "NODE_NO_WARNINGS=1 node node_modules/.bin/jest --no-cache --bail". My machine is i5 with 16GB RAM. Jest is 29.7.0 – Autograft
J
0

I was getting this issue because I forgot to switch to the correct Node version for my project before running jest πŸ˜…, e.g. nvm use 18.

Jimenez answered 15/5 at 21:24 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.