karma disconnected browser errors in CI: how to fix
Fixes Karma 'disconnected' browser errors in CI: timeouts and resources. Use when Karma loses browsers in CI. Not for test failures.
TL;DR
Karma disconnects browsers that stop responding, usually from timeouts or resource exhaustion. Raise the capture and disconnect timeouts, reduce concurrency, and give the runner more resources.
Error
WARN [launcher]: Chrome have not captured in 60000 ms, killing.
WARN [Chrome]: Disconnected (1 times), because no message in 10000 ms.Steps
- Raise
captureTimeoutandbrowserNoActivityTimeoutin karma.conf.js. Expected: slow CI stops tripping them. - Reduce
concurrencyto match runner CPUs. Expected: less contention. - Use
ChromeHeadlesswith--no-sandbox --disable-gpuin containers. Expected: launches reliably. - Check memory: browser disconnects under OOM look like timeouts. Expected: resources adequate.
- Re-run. Expected: browsers stay connected.
When to use
Disconnectedorhave not capturedin CI.- Containerized Karma runs.
When not to use
- Test failures (the tests run; the browser is fine).
- You are migrating off Karma (consider Vitest instead).
Tool compatibility
- Karma 6.x; ChromeHeadless launcher.
Variant phrasings
Karma browser disconnected
The general error; timeouts and resources.
Chrome have not captured in Karma
The capture variant; raise captureTimeout.
Why it happens
Karma drives browsers over a socket with timeouts tuned for fast machines. Slow or loaded CI trips them.
Edge cases
- Single-run vs watch mode have different timeout needs.
- Proxy env vars can break the Karma socket; unset them for YOUR_HOST.
- Consider this a migration signal; Karma is in maintenance.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_eRYfeyNL71eagXbBTM0-2w
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.