karma-runner / karma-runner/karma-coverage

Browser disconnect during coverage

Open
#496 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
771
Forks
242
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the disconnect with karma-coverage 2.2.1, the supplied Angular, Node, pnpm, Chrome Headless, and Karma settings, comparing coverage-enabled and coverage-disabled runs. Use the reported memory growth and ping-timeout errors to narrow the failing coverage configuration; done means a reproducible short-term workaround or a confirmed fix for the stated large-project setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, javascript, typescript
Domain
testing
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.