Skip to content
Latchkey

Angular karma "Disconnected, reconnect failed" timeout in CI

karma disconnected the browser because it received no message within the configured timeout. On a busy or memory-constrained runner the headless Chrome stalls long enough that karma gives up, failing the run intermittently.

What this error means

ng test fails with "Disconnected (0 times), because no message in 30000 ms." or "reconnect failed before timeout of 2000ms", often flaky across runs.

karma
Chrome Headless: Disconnected (0 times), because no message in 30000 ms.
Chrome Headless failed 1 tests
TOTAL: 1 FAILED

Common causes

The browser stalled under CPU or memory pressure

A constrained runner slows the headless browser enough that it misses karma pings, so karma disconnects it.

Default browser timeouts too short for CI

karma's default browserNoActivityTimeout can be too aggressive for a loaded CI runner and disconnects a browser that is merely slow.

How to fix it

Raise karma browser timeouts

Increase browserNoActivityTimeout and disconnect tolerance so a slow-but-alive browser is not dropped.

karma.conf.js
browserNoActivityTimeout: 60000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 2,

Reduce load and single-run headless

Run a single headless browser with --no-sandbox and avoid parallel heavy jobs on the same runner.

Terminal
npx ng test --watch=false --browsers=ChromeHeadlessCI

How to prevent it

  • Set generous karma browser timeouts for CI runners.
  • Run a single headless browser and keep the runner from being overloaded.
  • Use a runner with enough CPU/memory for the test browser.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →