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

Browser disconnect during coverage #496

Open
arobinson opened this issue Dec 5, 2023 · 1 comment
Open

Browser disconnect during coverage #496

arobinson opened this issue Dec 5, 2023 · 1 comment

Comments

@arobinson
Copy link

We are experiencing disconnects of the browser almost 100% of the time with karma-coverage. It used to happen on occasion, but now it happens consistently. On a MacBookPro it rarely happens, but we do see the CPU hit hard and memory usage go up to large numbers (node process at 6GB and browser at 2.5-3 GB). On an 8GB AWS Linux EC2, the browser disconnects. In the past, before I disabled our code's console logging, it was not uncommon to core dump the chromium process during unit tests.

This is the error message we get:

00:53:47.061  Chrome Headless 112.0.5614.0 (Linux x86_64) ERROR
00:53:47.061    Disconnected reconnect failed before timeout of 2000ms (ping timeout)
00:53:47.061  Chrome Headless 112.0.5614.0 (Linux x86_64) ERROR
00:53:47.061    Disconnected reconnect failed before timeout of 2000ms (ping timeout)
00:53:47.061  Chrome Headless 112.0.5614.0 (Linux x86_64) ERROR
00:53:47.061    Disconnected reconnect failed before timeout of 2000ms (ping timeout)

Turning coverage off fixes the issue, but as a result we have no code coverage.

We are using karma-coverage version 2.2.1

Angular environment:

Angular CLI: 16.2.4
Node: 18.17.0
Package Manager: pnpm 8.6.12
OS: darwin arm64

Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1602.4
@angular-devkit/core         16.2.4
@angular-devkit/schematics   16.2.4
@schematics/angular          16.2.4

Karma coverage settings:

{
    plugins: [karmaCoverage],
    coverageReporter: {
      type: 'html',
      dir: coverageDirectory,
      subdir: '.',
      includeAllSources: true,
      reporters: [
        { type: 'html', subdir: '.' },
        { type: 'lcov', projectRoot: projectDirectory }
      ] as any
    }
  }

Other karma settings:

{
    browserDisconnectTimeout: 25_000,
    browserDisconnectTolerance: 0,
    browserNoActivityTimeout: 600_000,
    captureTimeout: 600_000,
    browserSocketTimeout: 19_200_000,
    pingTimeout: 19_200_000,
    processKillTimeout: 10_000
  }

I've tried also disabling includeAllSources. I've also played around with trying to exclude files to cover in the angular JSON using codeCoverageExclude but no help

We have a large project, with ~550 spec files and 16,000 unit tests. Our source code, including the tests, is approximately 1 million lines of typescript code.

We are looking to potentially break up our code into Angular libraries in the future, but I'm looking for a more short-term work-around for this issue

Any assistance would be appreciated.

@KevinPartingtonTR
Copy link

KevinPartingtonTR commented Dec 5, 2024

I'm running into similar issues with our large project. At this point, the only option I think we have in my project is splitting code into Angular libraries, so we're doing that right now.

It's very unfortunate that this issue hasn't even had a reply from anyone in the karma-coverage community, but I guess it's to be expected when Karma itself is deprecated.

EDIT: Oh, forgot to mention that one "option" might be to disable source maps. This results in tests/coverage completing for us-- however, the coverage report is inaccurate and trends low. So, not a great option at all. But it could be useful in the short term if your actual code coverage is moderately higher than any thresholds you have set.

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

No branches or pull requests

2 participants