Issue
Jenkins builds running Karma tests with Chrome/Chromium 146 in Docker containers fail with D-Bus connection errors:
ERROR [launcher]: Cannot start Chrome [ERROR:dbus/bus.cc:405] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory [ERROR:dbus/bus.cc:405] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")
After addressing the initial D-Bus errors, builds may also fail with a ping timeout during test execution:
WARN [Chrome Headless 146.0.0.0 (Linux 0.0.0)]: Disconnected (0 times) reconnect failed before timeout of 300000ms (ping timeout) Chrome Headless 146.0.0.0 (Linux 0.0.0) ERROR Disconnected reconnect failed before timeout of 300000ms (ping timeout)
These errors prevent the test suite from completing successfully.
Explanation
Chromium 146 introduced a new unified headless browser engine, replacing the previous --headless=old mode. This new engine automatically attempts to connect to the Linux system D-Bus for crash reporting and system integration. Docker containers do not run D-Bus by default, causing these connection attempts to fail.
Additionally, passing DBUS_SESSION_BUS_ADDRESS = '/dev/null' uses an invalid raw file path format. Chrome requires the D-Bus URI address format (unix:path=/dev/null), which explains the "Unknown address type" error.
The ping timeout error occurs because the new headless engine requires more V8 JavaScript engine heap memory to process large test suites with code coverage generation.
Workaround
Update the Jenkinsfile environment block
Add the following environment variables to the test stage to redirect D-Bus connections to /dev/null:
stage('Test') { environment { DBUS_SESSION_BUS_ADDRESS = 'unix:path=/dev/null' DBUS_SYSTEM_BUS_ADDRESS = 'unix:path=/dev/null' XDG_RUNTIME_DIR = '' CHROME_HEADLESS = '1' } steps { sh 'npm test' } }
Use the unix:path=/dev/null URI format for both DBUS_SESSION_BUS_ADDRESS and DBUS_SYSTEM_BUS_ADDRESS. A raw file path (/dev/null) is not recognized by Chrome and produces the "Unknown address type" error.
|
Update the karma.conf.js customLaunchers block
Switch the base to Chrome and explicitly pass the --headless flag. Also add the --js-flags option to allocate sufficient V8 heap memory for the test suite:
customLaunchers: { ChromeHeadless: { base: 'Chrome', flags: [ '--disable-gpu', '--headless', '--remote-debugging-port=9222', ], }, ChromeHeadlessNoSandbox: { base: 'Chrome', flags: [ '--headless', '--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--disable-extensions', '--remote-debugging-port=9222', '--disable-software-rasterizer', '--disable-features=VizDisplayCompositor', '--disable-crash-reporter', '--js-flags=--max-old-space-size=8192', ], }, },
--js-flags=--max-old-space-size=8192 allocates 8 GB of V8 heap memory to the browser process. Adjust this value to match the available memory on the CI agent (for example, 4096 for 4 GB).
|