#53022: fix: exit cleanly when the D-Bus session bus goes away on Linux
Description of Change
dbus::Bus runs LOG(FATAL) ("D-Bus connection was disconnected. Aborting.") when libdbus delivers the local Disconnected signal. That fits Chrome OS, where a dbus-daemon crash takes the device down anyway, but on desktop Linux the session bus routinely goes away under a running app: at logout, on systemctl --user restart dbus, or when dbus-broker is restarted by a package upgrade. Each of those ended in a crash report instead of an exit.
The bus gets a disconnected_callback option, with FATAL kept as the default so nothing changes for buses that don't set it, plus a downstream-only hook, dbus_thread_linux::SetDisconnectedCallback(), for the shared session and system buses (upstream will pass the callback at creation once https://chromium-review.googlesource.com/c/chromium/src/+/8009126 replaces their lazy statics). Both are wired to the same exit path the display-server loss already uses, so a lost bus exits exactly like a lost display: ExitWithCode(RESULT_CODE_NORMAL_EXIT) under the 10 s watchdog.
The spec starts a private dbus-daemon, points both bus addresses at it, kills it once the app has connected, and expects exit code 0 with no signal. Against stock 42.7.0 the same run ends in exit 133 (IMMEDIATE_CRASH from the FATAL); with the bus left up the stock build stays alive.
Upstream: https://chromium-review.googlesource.com/c/chromium/src/+/8261571
Checklist
- PR description included and stakeholders cc'd
-
npm testpasses - tests are changed or added
- PR title follows semantic commit guidelines
Release Notes
Notes: Fixed a crash on Linux when the D-Bus session bus disconnected while the app was running, such as at logout or when dbus is restarted.
Backports
Semver Impact
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron