-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running tests with coverage causes CPU to hit 100% after tests finish #454
Comments
Same environment, same symptoms here: https://github.com/mmomtchev/sqlite-wasm-http/actions/runs/4377210809/attempts/1 |
Node v19 does not solve it |
How large does the |
44 MB in 90 files, all in |
That doesn't sound too bad. I've seen cases where CIs get slow when But getting a CI stuck with 44MB files sounds like a different issue. |
The CI build I linked to was killed after having stalled for six hours. Prior to the appearance of this bug processing the coverage report in CI took seconds so I definitely think it's a different issue! |
I am running into the same issue. Able to run the tests and coverage successfully locally inside the applications' docker container (based on node:18.14.2-bullseye-slim). Using the same container in the Gitlab CICD environment I do get test results on stdout but hangs when generating coverage. Using the following Gitlab config (already commented out most of the post-processing stuff for debugging):
My coverage/tmp only gets to 2MB (really small app) |
Try adding |
as suggested in bcoe/c8#454
* add NODE_DEBUG as suggested in bcoe/c8#454 * try windows * change the correct job * use npx * remove NODE_DEBUG
@AriPerkkio It seems that Windows is not affected PS. Finally, Windows is affected too, but the frequency is much lower |
@achingbrain Did you find any solution? |
No, currently running tests without coverage due to this issue. |
Somebody has to fix it. I can't reproduce it outside of Github Actions. Try attaching the inspector when it happens. |
What do you mean by attaching in inspector, how can I help you? I can reproduce this error in the local environment with node 16.14, I tried to find debug logs to report to you but the attempt was not successful! also, my problem was solved with |
I was able to reproduce it with |
The workaround that helped me is to enable the Seems that there is some mutual issue in handling the exit between c8 and Mocha running as a child process. I suspected that there is some loop or wait process on the Mocha side waiting for something to finish after waiting for the tests. I was unable to attach the debugger to the Mocha child process, Node seems to be in the phase when it does not accept debugger connections anymore. Then I tried
If I'm not missing anything, then I guess what happens is that Mocha's process gets stalled waiting until the stdout pipe is read just before exiting, while the c8 process perhaps is not reading enough from this pipe to let Mocha's Node process finish. The workaround helps by making Mocha flush and exit the process explicitly after completing the tests. See the flag description for the dangers of the exit mode: https://mochajs.org/#-exit I'm using macOS, btw, and the issue is occurring ~10% of time for me locally. |
I also have no issues when running Mocha directly with the same arguments. |
Still having the issue with |
I wonder if this could be related to nodejs/node#49344 we should keep an eye and see if the problem continues once patched. |
I don't know if my issue is related to this issue. I use ava with c8. When I use node 18, it's working, but when I upgrade to node 20, c8 will hang forever after ava test finished. When I use node 18: $ npm test
...
✔ application › should schedule a job (2s)
─
7 tests passed
--------------------------|---------|----------|---------|---------|-------------------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------------------|---------|----------|---------|---------|-------------------------------
All files | 83 | 86.36 | 70.83 | 83 |
_core | 87.73 | 91.66 | 80 | 87.73 |
application.ts | 87.73 | 91.66 | 80 | 87.73 | 86-94,167-169,177-178,184-195
_core/controller | 76.92 | 100 | 75 | 76.92 |
route.ts | 76.92 | 100 | 75 | 76.92 | 35-49
_core/controller/actions | 68.75 | 60 | 75 | 68.75 |
health.ts | 100 | 100 | 100 | 100 |
siweAction.ts | 63.41 | 50 | 66.66 | 63.41 | 15-18,28-29,33-41
_core/services | 80.3 | 70 | 25 | 80.3 |
dbService.ts | 75 | 100 | 0 | 75 | 20-22,25-27,30-31
securityService.ts | 85.29 | 70 | 100 | 85.29 | 11-12,16-17,29
_core/utils | 100 | 100 | 100 | 100 |
common.ts | 100 | 100 | 100 | 100 |
--------------------------|---------|----------|---------|---------|------------------------------- But when I use node 20, the same code with test will hang: $ npm test
> sln-a@0.1.0 test
> c8 ava
...
✔ application › should schedule a job (2s)
# <==== hang forever and I have to kill node process to stop it
# no tests result output and ctrl-c is not working
|
Node.js 21.6.0 which includes the fix for nodejs/node#47748 resolved the issue for me. |
When running tests with coverage in CI, after the test run completes successfully, CPU spikes to 100% and the process hangs.
It happened in this build: https://github.com/ipfs/aegir/actions/runs/4225847659/jobs/7338650232 and sometimes happens locally too, though it's a lot more frequent in CI.
This started happening with node 18, it didn't seem to happen with node 16.
The command being run is similar to:
The text was updated successfully, but these errors were encountered: