[Bug]: gh credential lookups leak a dbus-daemon per call on hosts without a session bus (WSL)#23603

opened19d agobyHhelixnebulatech

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Run the T3 Code server on a host with no D-Bus session bus: WSL2, or headless Linux, where DBUS_SESSION_BUS_ADDRESS is unset and /run/user/<uid>/bus does not exist.
  2. Sign gh in with its token stored in ~/.config/gh/hosts.yml, which is what gh auth login does when no keyring is available.
  3. Open a project whose remote makes T3 ask gh for a token gh does not have in its config, for example an SSH alias remote git@github-hn:owner/repo.git (Host github-hn / HostName github.com in ~/.ssh/config), or pick a GitHub account in Settings → Source Control so T3 runs gh auth token --user <account>.
  4. Leave T3 running and watch pgrep -cx dbus-daemon.

Expected behavior

T3's background gh calls leave no processes behind.

Actual behavior

Every gh auth token call that reaches gh's keyring starts a new dbus-daemon that never exits. gh reads the keyring through godbus (v5.2.2 in gh 2.97.0). With no session bus address, godbus autolaunches one with dbus-launch, and that daemon outlives gh. gh auth status --json hosts does the same for hosts with inactive accounts.

T3 repeats these calls whenever it refreshes git status or syncs pull requests. On my machine that added up to 162 orphaned dbus-daemon processes, re-parented to WSL's /init, in about five hours. Each one holds an inotify instance, and once fs.inotify.max_user_instances (128) ran out, unrelated programs crashed. OpenCode would not start: EMFILE: too many open files from fs.watch.

I traced the spawns with a logging dbus-launch shim on PATH. Every one came from gh auth token --hostname github-hn or --hostname github-ng, run by the T3 server process. The server trace shows these lookups under refineUnknownRemoteProvider, reached from ThreadPullRequestServiceV2.synchronize, ThreadSettlementServiceV2.sweep and RunFinalizationService.finalize.

Impact

Major degradation or frequent failure

Version or commit

T3 server 0.1.1 (WSL runtime); code path unchanged on main @ 8d3b0611

Environment

Windows 11 + WSL2 (Gentoo, kernel 6.18.33.2-microsoft-standard-WSL2), gh 2.97.0, desktop app running the server in WSL

Logs or stack traces

shell
1$ pgrep -cx dbus-daemon
2162
3$ ps -o ppid=,cmd= -C dbus-daemon | sort | uniq -c | head -1
4 162 69 /usr/bin/dbus-daemon --syslog --fork --print-pid 4 --print-address 6 --session
5$ cat /proc/sys/fs/inotify/max_user_instances
6128
7
8# dbus-launch shim log (caller chain)
9== 16:35:05 dbus-launch
10 ^ gh auth token --hostname github-hn
11 ^ /home/<user>/.t3/wsl-runtime/<hash>/t3 --bootstrap-fd 0
12
13# gh alone, no session bus
14$ gh auth token --hostname github-hn # exit 1, +1 dbus-daemon
15$ gh auth token --hostname github.com --user <me> # exit 0, +1 dbus-daemon
16$ DBUS_SESSION_BUS_ADDRESS=disabled: gh auth token --hostname github-hn # exit 1, +0

Workaround

Kill the orphaned daemons, then give gh a shared session bus: start one dbus-daemon --session and export its address, or put a dbus-launch shim on T3's PATH that returns an existing bus address instead of starting a new one.

A fix is proposed in #23549. The SSH-alias misclassification that triggered the calls here is tracked separately in #14919.

Reproduced on 22840ab943 with the real app on Ubuntu/Xvfb and gh 2.97.0, with no session bus: adding the alias-remote project increased D-Bus daemons from 2 to 4. The preserved fix in #23824 keeps repeated lookups at 2 and preserves a configured bus address.

[GPT-6.1-Sol][Codex] on behalf of shivam.

Issue watch found that Julius already owns this fix in https://github.com/pingdotgg/t3code/pull/23824, which closes this issue. Its current head is 0dd6c9fdfe5802104768fb96b48c64a89dbdcd8f. No independent reproduction or code changes were made in this thread. Handing off to that PR and stopping this duplicate job.