Diagnosing Karma Browser-Launch Failures in CI & Local Workflows
When Karma tests hang or report Disconnected, the cause is usually a missing Chrome binary, mismatched launcher config, or CI-specific sandbox flags. This guide walks through diagnosis and fixes.
07 Apr 2026, 15:20 UTC

Problem: Karma Tests Hang or Report Disconnected in CI
You execute karma start in a continuous integration pipeline or on a headless workstation. The Karma server starts and reports a browser, but tests never begin or finish with a Disconnected status. The process may also hang indefinitely if singleRun is not configured.
Diagnostic Table: Condition to Likely Cause
| Symptom | Likely Cause |
|---|---|
| Tests hang, never exit | singleRun: false in CI |
| Disconnected browser status | Missing or mismatched Chrome/Chromium binary |
| Repeated launch attempts in logs | CHROME_BIN not set or wrong browsers array |
| Launch fails in container | Missing --no-sandbox flag |
Ordered Checks
Verify the Chrome/Chromium binary. Run
google-chrome --headless --versionorchromium --versionin the CI shell. If the command is not found or returns an error, Karma cannot launch a browser. Install the binary or set theCHROME_BINenvironment variable to its absolute path.Confirm the
browsersarray matches installed launchers. Inkarma.conf.js, thebrowserslist (e.g., "ChromeHeadless") must correspond to a launcher package innode_modulessuch askarma-chrome-launcher. Runnpm list karma-chrome-launcherto verify the package is present.Inspect debug logs for launch attempts. Start Karma with
logLevel: DEBUG. Look for lines indicating the browser was launched and captured, or repeated attempt messages without success. If you see Attempting to launch Chrome followed quickly by Disconnected, the binary path or flags may be misconfigured.Check
singleRunandautoWatchsettings. In CI, setsingleRun: trueso Karma exits after tests complete. Leaving it false causes the process to wait for manual browser capture, which pipelines do not expect. Similarly,autoWatch: trueis intended for local development; disable it in CI pipelines.Add container-specific flags if needed. On Linux running as root or in Docker, Chrome often requires the
--no-sandboxflag to start. You can inject it viacustomLaunchersinkarma.conf.js:
Then update thecustomLaunchers: {"chrome-ci": {"base": "ChromeHeadless", "flags": ["--no-sandbox", "--disable-gpu", "--disable-dev-shm-usage"]}}browsersarray to reference the custom launcher:["chrome-ci"].
Fixes Tied to Findings
- Missing binary: Install Chrome or Chromium, or set
CHROME_BIN=/opt/chrome/chrome(or wherever the binary lives) in the environment before running Karma. - Mismatched
browsersarray: Align the array value with the installed launcher package name, or rename the custom launcher entry to match whatkarma-chrome-launcherexpects. - Repeated failed launch attempts: Correct
CHROME_BINor fix thebrowsersvalue after inspecting the DEBUG output. - Container launches failing: Add
--no-sandboxviacustomLaunchersflags (see example above) or the Docker/CI runner's runtime flags. Note:--no-sandboxreduces Chrome isolation and should only be used in trusted CI containers, not on general developer workstations. - Tests hang because
singleRun: false: Change totruefor CI, or manually capture a browser by opening the Karma server address printed in the terminal if you need interactive debugging.
Escalation Criteria
If none of the ordered checks resolve the issue, gather the following before escalating:
- Full
karma startoutput withlogLevel: DEBUG - Output of
google-chrome --headless --versionorchromium --version - Karma and Node.js versions (
npm list karmaandnode --version) - Operating system and container runtime details (e.g., Docker version, Kubernetes node labels)
At this point, the problem may involve an unsupported Chrome version, a custom launcher plugin, or a permission issue outside Karma's default configuration.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.