Open MichaelPeter opened 2 years ago
Seems to be actually a problem of the test runner container, closing this for now:
https://github.com/trion-development/docker-ng-cli-karma/issues/14
I have the same problem - when running directly via ng test
(angular cli) it terminates fine, but when using an npm script it hangs. This is reproducible on my local machine with karma-browserstack-launcher and latest versions of angular (14.0.3) and karma (6.4.0).
Debug output before it hangs:
...
29 06 2022 13:10:49.487:DEBUG [karma-server]: Run complete, exiting.
29 06 2022 13:10:49.488:DEBUG [launcher]: Disconnecting all browsers
29 06 2022 13:10:49.489:DEBUG [proxy]: Destroying proxy agents
29 06 2022 13:10:49.490:DEBUG [launcher.browserstack]: Shutting down BrowserStackLocal
29 06 2022 13:10:54.570:DEBUG [launcher.browserstack]: Stopped BrowserStackLocal
29 06 2022 13:10:55.656:DEBUG [launcher.browserstack]: Chrome (Windows 10) (worker 117976169) successfully killed.
29 06 2022 13:10:55.658:DEBUG [launcher]: Finished all browsers
29 06 2022 13:10:55.658:DEBUG [launcher]: null -> FINISHED
29 06 2022 13:10:55.659:DEBUG [launcher]: FINISHED -> FINISHED
29 06 2022 13:10:55.662:DEBUG [karma-server]: Received stop event, exiting.
29 06 2022 13:10:55.663:DEBUG [launcher]: Disconnecting all browsers
29 06 2022 13:10:55.663:DEBUG [proxy]: Destroying proxy agents
29 06 2022 13:10:55.664:DEBUG [launcher.browserstack]: Shutting down BrowserStackLocal
29 06 2022 13:10:55.705:DEBUG [launcher]: FINISHED -> FINISHED
Hi,
I am experiencing exactly the same issue in my project after upgrading it to Angular 14. It was working fine on Angular 12.
@daniel-sc , @MichaelPeter , if you find any work around, can you please share it?
Hi @ravasconcelos, we solved it by switching to Chrome instead of using ChromeHeadless since there is no exit script for it. So: browsers: ['Chrome']
Hope it helps you, too.
We have the same Issue after upgrading to Angular 14.
Is there any workaround until now ?
Hi @RobinMobers97 , this hack worked for me: https://github.com/karma-runner/karma-browserstack-launcher/issues/195#issuecomment-1204786412
I hope it will be fixed soon.
Hi,we have the same Issue after upgrading to Angular 14.
Will this be fixed soon?
have you tried to switch from ChromeHeadless to browsers: ['Chrome'] in your karma.conf.json? This worked for us :)
@mrs-cp yes, we tried, but it doesn't work :(
have you updated your docker images to trion/ng-cli:14.2.1 or trion/ng-cli-karma:14.2.1, respectively?
plus we set singleRun: true
+ autoWatch: false
in our karma.conf.json
@mrs-cp yes, i experienced in trion/ng-cli-karma:13... that ng test exits but npm run test dont but in trion/ng-cli-karma:14.2.1 no way (ng test | npm run test) exits
so we have to use trion/ng-cli-karma:13 and ng test for now
Had a similar issue on github... oddly enough disabling analytics in the ng cli
was the trick to get this stable.
Do one of the following:
NG_CLI_ANALYTICS=false
ng analytics disable
"cli": {
"analytics": false
}
Any update on this?
We are also facing the same problem on angular 15.x and 16.x We use maven frontend plugin to build our angular UI, We also tried a new ng app(version 15 and 16) with same frontend plugin, same problem. So It is something in the library.
We tried the hacks provided here but unfortunately, they did not work for us. Anyone able to find some workaround, please share. For now we are migrating our tests to Jest but that's not an ideal way.
Hi!! I fixed the problem and I post in here https://github.com/trion-development/docker-ng-cli-karma/issues/14#issuecomment-1648243510.
So I've got a flavor of this happening with Karma (v6.4.3) being called by Angular's test runner in CI with the following command:
npx ng test --no-watch --browsers=ChromeHeadlessNoSandbox
In researching the problem, I found: https://github.com/karma-runner/karma-browserstack-launcher/issues/195#issuecomment-1204786412
The suggestion therein is simply to add a process exit at the end of the close event on the web server. That would be here: https://github.com/karma-runner/karma/blob/84f85e7016efc2266fa6b3465f494a3fa151c85c/lib/server.js#L473
The "hacky workaround" therein was to add
process.nextTick(() => process.exit(code || 0));
after the removeAllListeners() call. I tried this on my own machine (not the CI host) and it didn't seem to break anything, although I've never had this hangup on my host, just CI.
Looking above, I wonder if the
done(code || 0)
already up there on line 468 would work similarly.
Just food for thought, I'll probably try this out in the next few days, a few folks in the linked thread suggested this helped them with troubles in this area.
I checked already the troubleshooting guide. We recently upgraded from angular 12 to angular 14 and since then our pipline gets stuck on testing inside the gitlab pipline after executing all tests, but not on our local maschines.
Now if we execute ng test on our pcs, the testsuite executes, but if our CI pipline in Gitlab (which provisions Kubernets Pods) executes the tests it gets stuck after executing all tests and does not exit anymore (we waited up to an hour)
We have a angular solution with about 10 projects and every project has its own karma config, which are all quite simular. If we even remove the tests for the last project still the same error happens.
Here is the end of the debug log.
As you can see it gets stuck after Destroying proxy agents
Any ideas/tips how I could fix it, work arround it?
One Idea is that our pods don't have too much memory and that the pods run out of memory, but then we still need a solution.
The docker image executing the tests is the latest version of
trion/ng-cli-karma
https://hub.docker.com/r/trion/ng-cli-karma/tagsHere is the command line:
ng test --code-coverage --no-watch --browsers=ChromeHeadless --source-map=false
here the karma config of the last project ot be exeucted, but they are essentially the same
and here the depedencies of our package.json
As you can see we upgraded to the latest versions
Thank you very much for your time!