jest
jest copied to clipboard
[Bug]: Jest worker encountered 3 child process exceptions, exceeding retry limit
Version
28.1.2
Steps to reproduce
https://github.com/shaobeichen/blog
yarn
yarn test:coverage
Expected behavior
no error
Actual behavior
$ yarn test:coverage
yarn run v1.22.19
$ jest --coverage --maxWorkers 2 --unhandled-rejections=warn
PASS src/components/abstract/toast/tests/toast.test.ts
√ 创建一个弹窗,持续3秒 (13 ms)
√ 命令式调用,创建一个弹窗 (12 ms)
Running coverage on untested files...Failed to collect coverage from D:\work\blog\src\utils\request\base.ts
ERROR: Jest worker encountered 3 child process exceptions, exceeding retry limit
STACK: Error: Jest worker encountered 3 child process exceptions, exceeding retry limit
at ChildProcessWorker.initialize (D:\work\blog\node_modules\jest-worker\build\workers\ChildProcessWorker.js:170:21)
at ChildProcessWorker._onExit (D:\work\blog\node_modules\jest-worker\build\workers\ChildProcessWorker.js:254:12)
at ChildProcess.emit (node:events:520:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
Failed to collect coverage from D:\work\blog\src\utils\request\mofish.ts
ERROR: Jest worker encountered 3 child process exceptions, exceeding retry limit
STACK: Error: Jest worker encountered 3 child process exceptions, exceeding retry limit
at ChildProcessWorker.initialize (D:\work\blog\node_modules\jest-worker\build\workers\ChildProcessWorker.js:170:21)
at ChildProcessWorker._onExit (D:\work\blog\node_modules\jest-worker\build\workers\ChildProcessWorker.js:254:12)
at ChildProcess.emit (node:events:520:28)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
-------------------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 20.86 | 30 | 15.38 | 20.83 | |
src | 0 | 100 | 100 | 0 | |
main.ts | 0 | 100 | 100 | 0 | 1-13 |
src/api | 0 | 100 | 0 | 0 | |
toast.d.ts | 0 | 0 | 0 | 0 | |
src/utils | 100 | 100 | 100 | 100 | |
sleep.ts | 100 | 100 | 100 | 100 | |
src/utils/request | 0 | 100 | 100 | 0 | |
index.ts | 0 | 100 | 100 | 0 | 1-6 |
------------------------------- | --------- | ---------- | --------- | --------- | ------------------- |
Test Suites: 1 passed, 1 total | |||||
Tests: 2 passed, 2 total | |||||
Snapshots: 0 total | |||||
Time: 8.779 s | |||||
Ran all test suites. | |||||
Done in 9.76s. |
Additional context
"test:coverage": "jest --coverage --maxWorkers 2"
not work
Environment
System:
OS: Windows 10 10.0.22000
CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-11320H @ 3.20GHz
Binaries:
Node: 16.14.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.3.1 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^28.1.2 => 28.1.2
I am having the exact same issue (obviously with a different file though). The differences in my environment are:
OS - MacOS Monteray v12.4 Node - v18.2.0 NPM - v8.9.0 jest - 28.1.3
Hi I'm also facing the same issue, what is the reason for this Node v16.15.1 NPM 8.11.0 jest 28.1.3
I can also reproduce it with this environment: Windows 10 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHZ Node v16.15.0 NPM : 8.5.5 jest 28.1.3
With Jest 27 I didn't have the problem, when I switched to Jest 28 I had the same error.
I had problems importing in the files where I had this error.
I don't know why it was not a problem with the build and with version 27.
Now it works
With Jest 27 I didn't have the problem, when I switched to Jest 28 I had the same error.
I had problems importing in the files where I had this error.
I don't know why it was not a problem with the build and with version 27.
Now it works
oh thanks, i'll try it tonight
My issue was with mocks, after fixing them issue got resolved
As noted in the Bug Report template, all bug reports requires a minimal reproduction. Please open up a new issue providing one. Read more at https://stackoverflow.com/help/minimal-reproducible-example.
My issue was with mocks, after fixing them issue got resolved
@wkul9429 how exactly did you fix it?
I had exact same error message on CI tests. It affected all my test cases. This message hides real problem. You have to change maxWorkers to 1 to see what is the problem on single thread. Then you will see cause of error which helps you to resolve issue.
It appears that Node 15 introduced a breaking change to promise rejection handling. Reference https://developer.ibm.com/blogs/nodejs-15-release-blog/
yes, it's the problem. And it turned out debugging of unhandled rejected promises is so painful
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.