Skip to content
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

Karma sometimes generates Error: read ECONNRESET after successful test run #3295

Open
fr0 opened this issue Apr 8, 2019 · 12 comments · May be fixed by #3402
Open

Karma sometimes generates Error: read ECONNRESET after successful test run #3295

fr0 opened this issue Apr 8, 2019 · 12 comments · May be fixed by #3402

Comments

@fr0
Copy link

fr0 commented Apr 8, 2019

Expected behaviour

This started happening intermittently after I upgrade from 3.1.3 to 3.1.4, and it has been happening ever since (not every time -- about 1/3 to 1/2 of the time). ( After looking through the changelog, I'm inclined to suspect cc2eff2 )

The error I get is:

$ karma start karma.conf.js --single-run --jenkins
21 02 2019 09:43:38.104:INFO [compiler.karma-typescript]: Compiling project using Typescript 3.2.4
21 02 2019 09:43:53.795:INFO [compiler.karma-typescript]: Compiled 21 files in 15446 ms.
21 02 2019 09:43:57.633:INFO [bundler.karma-typescript]: Bundled imports for 21 file(s) in 3328 ms.
21 02 2019 09:43:59.695:INFO [karma-server]: Karma v4.0.0 server started at http://0.0.0.0:9876/
21 02 2019 09:43:59.720:INFO [launcher]: Launching browsers ChromeHeadless with concurrency unlimited
21 02 2019 09:43:59.757:INFO [launcher]: Starting browser ChromeHeadless
21 02 2019 09:44:01.220:INFO [HeadlessChrome 72.0.3626 (Windows 10.0.0)]: Connected on socket 16JL3Xy0xm-ri3aBAAAA with id 59122393
HeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 0 of 110 SUCCESS (0 secs / 0 secs)
[1A[2KHeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 1 of 110 SUCCESS (0 secs / 0.061 secs)
...
[1A[2KHeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 110 of 110 SUCCESS (2.695 secs / 2.341 secs)
TOTAL: 110 SUCCESS
21 02 2019 09:44:05.251:ERROR [karma-server]: { Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command

Actual behaviour

Error: read ECONNRESET

Environment Details

Karma version: 4.0.1
Operating System: Windows 10 64-bit

See: https://stackoverflow.com/questions/54809981/how-do-i-debug-errors-from-karma-server

Steps to reproduce the behaviour

Unfortunately I cannot share my repo, since it is private. If someone can guide me on how to track down the source of this error, I'd be happy to do the heavy lifting.

@johnjbarton
Copy link
Contributor

I'm surprised by this part of the output:

21 02 2019 09:44:01.220:INFO [HeadlessChrome 72.0.3626 (Windows 10.0.0)]: Connected on socket 16JL3Xy0xm-ri3aBAAAA with id 59122393
HeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 0 of 110 SUCCESS (0 secs / 0 secs)
[1A[2KHeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 1 of 110 SUCCESS (0 secs / 0.061 secs)
...
[1A[2KHeadlessChrome 72.0.3626 (Windows 10.0.0): Executed 110 of 110 SUCCESS (2.695 secs / 2.341 secs)
TOTAL: 110 SUCCESS

Is the 'progress' reporter running?

It looks like the test executes and passes, so perhaps the browser is being killed out of order withh the socket close?

Try running with logLevel debug and compare error and not-error cases.

@fr0
Copy link
Author

fr0 commented Apr 9, 2019

Sorry, the ... is just the part in the middle that I clipped out for brevity.
Yes, the 'progress' reporter is running.
I will try running with logLevel and get back to you. Thanks for the reply!

@fr0
Copy link
Author

fr0 commented Apr 9, 2019

Here are the logs for both the failure case and success case.
failure.log
success.log

@johnjbarton
Copy link
Contributor

johnjbarton commented Apr 9, 2019

The key parts:
FAIL :
09 04 2019 10:14:40.637:DEBUG [karma-server]: Run complete, exiting.
09 04 2019 10:14:40.638:DEBUG [launcher]: Disconnecting all browsers
09 04 2019 10:14:40.671:ERROR [karma-server]: { Error: read ECONNRESET
at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
09 04 2019 10:14:40.672:DEBUG [launcher]: Disconnecting all browsers
09 04 2019 10:14:40.674:DEBUG [launcher]: Process ChromeHeadless exited with code null and signal SIGTERM

SUCCESS:
09 04 2019 10:21:37.859:DEBUG [karma-server]: Run complete, exiting.
09 04 2019 10:21:37.860:DEBUG [launcher]: Disconnecting all browsers
09 04 2019 10:21:37.883:DEBUG [launcher]: Process ChromeHeadless exited with code null and signal SIGTERM

So it looks like the launcher kills the chrome process but the server does not know that the socket is dying on purpose. So the launcher and the server race to the next event. If the launcher wins, success. If the server wins fail.

@rdrrichards
Copy link

Can or will this issue be addressed at some point? Is there a work around?

@johnjbarton
Copy link
Contributor

This issue seems to be only about an annoying and erratic error message.
I suppose we should suppress the ECONNRESET error message after Run complete, exiting. Please send a PR.

mgroenhoff added a commit to mgroenhoff/karma that referenced this issue Dec 17, 2019
Karma sometimes reports uncaught exceptions (ECONNRESET) which causes it to exit the process with a non-zero exit code.

Fixes karma-runner#3295
@mgroenhoff mgroenhoff linked a pull request Dec 17, 2019 that will close this issue
@mgroenhoff
Copy link

@johnjbarton I sent a PR to fix this issue. This is currently making our automated tests fail because we rely on the exit code being 0.

@brodziakm
Copy link

Since upgrading to Angular 11 we are experiencing this problem.

I've verified a few things:

  • A new Angular 11 project with the default Karma test configuration does not experience this problem
  • Reapplying the default Karma configuration (taken from the new Angular 11 project) doesn't resolve the problem
  • Running a single test in our project works fine and doesn't exhibit the problem
  • Running a collection of tests or the whole suite exhibits the problem every single time
  • The attached PR resolves the issue

Will this PR be merged soon? We'd really appreciate it!

@johnjbarton
Copy link
Contributor

Sorry which PR has a proposed fix?

@rdrrichards
Copy link

@johnjbarton This is the PR: #3402

@costescuandrei
Copy link

Any update on this? This is still messing up the build on some comps.
Maybe the root cause of this should be dealt with as well? Like making it expect the browser disconnect (not fail) or disconnects happening in the reverse order?

@Panossa
Copy link

Panossa commented Oct 31, 2022

End of 2022 and this is still an issue. Started in our project like a week ago. Causes our local builds to fail but runs on Jenkins without any problems.

Edit: for more context: it stopped working locally, randomly, last week. Maybe it has something to do with a Chrome update? Our Jenkins runs on an older Chrome where it still works flawlessly but locally multiple devs suddenly got problems. (Current, not working Chrome build: 106.0.5249.121. My colleague has 107.0.5304.88 and it's not working for them, either.)

pmvald added a commit to mgroenhoff/karma that referenced this issue Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants