Skip to content

auth login/status hang silently when the Secret Service (gnome-keyring) is broken; no timeout or hint #14812

Open

Description

@ye-discernis

Describe the bug

gh auth login (and gh auth status) hang indefinitely, with no output and no error, when the Secret Service provider is in a broken state. In my case there were two gnome-keyring-daemon instances on the session bus after the daemon crashed and was restarted.

Each attempt triggered a desktop keyring unlock prompt, which appeared twice. Then gnome-keyring-daemon crashed. gh never timed out or reported anything. When run from a terminal where the desktop prompt isn't visible, it just hangs, so the one-time device code and the URL are never shown.

After the crash, two daemons were running:

  • gnome-keyring-daemon --start --foreground --components=secrets, D-Bus-activated (in dbus.service's cgroup)
  • gnome-keyring-daemon --foreground --components=pkcs11,secrets --control-directory=..., the systemd user unit gnome-keyring-daemon.service

Killing the D-Bus-activated instance and running systemctl --user restart gnome-keyring-daemon.socket gnome-keyring-daemon.service fixed it immediately. After a single keyring unlock, gh auth login -w worked normally.

Steps to reproduce the behavior

The trigger is environmental and hard to reproduce on purpose:

  1. Have a GNOME session where gnome-keyring-daemon crashes and a second instance gets D-Bus-activated next to the systemd-managed one, so two Secret Service owners exist.
  2. Have a stored token that is no longer valid (gh auth status reports "The token in default is invalid").
  3. Run gh auth login -h github.com -p ssh -w or gh auth status.
  4. gh blocks on the keyring call forever. No device code is printed, and there is no timeout or error.

Expected vs actual behavior

Expected: if the keyring / Secret Service call doesn't return within a reasonable time, gh fails with an actionable message. For example: "the system keyring did not respond; unlock it, or retry with --insecure-storage". For auth status, at least report that the keyring is unresponsive.

Actual: an indefinite silent hang. gh auth status hangs the same way.

Logs / environment

  • gh version 2.103.1 (2026-10-23)
  • Ubuntu 26.04.1 LTS, GNOME on Wayland
  • gnome-keyring 50.0 (gnome-keyring-daemon crash report recorded by apport at the time)

Related

A timeout plus a hint about --insecure-storage would have turned this into a self-explanatory error instead of an apparent freeze.

Activity

  1. cli-triage commented on Oct 24, 2026

    @cli-triage

    Thanks for the detailed report. I'm suggesting bug, priority-3, and gh-auth: this describes gh auth login/gh auth status failing to surface any error when the Secret Service (keyring) backend is in a broken state, but it looks like a narrow, environment-specific trigger (two competing gnome-keyring-daemon instances after a crash) with a workaround (restart the daemon, or --insecure-storage), so I'm not marking it P1/P2.

    I didn't find an exact duplicate. #7356 (closed) was an older, unrelated hang after selecting "GitHub.com", and #13317 is about silent unauthenticated fallback rather than hanging — both correctly linked by the reporter as "related," not duplicates.

    Hypothesis on the mechanism: each keyring operation already has a timeout, not an unbounded wait — keyring.Get gives up and returns a TimeoutError after 60 seconds (bumped up from 3 seconds specifically so interactive unlock prompts have time to be answered, see 0ca080d):

    func Get(service, user string) (string, error) {
    ch := make(chan struct {
    val string
    err error
    }, 1)
    go func() {
    defer close(ch)
    val, err := keyring.Get(service, user)
    ch <- struct {
    val string
    err error
    }{val, err}
    }()
    select {
    case res := <-ch:
    if errors.Is(res.err, keyring.ErrNotFound) {
    return "", ErrNotFound
    }
    return res.val, res.err
    case <-time.After(60 * time.Second):
    return "", &TimeoutError{"timeout while trying to get secret from keyring"}
    }
    }
    . AuthConfig.ActiveToken can call into the keyring more than once per invocation (via TokenForUser and then a TokenFromKeyring fallback), so what looks like an "indefinite" hang may actually be one or more sequential 60-second waits with no progress indicator — worse here because a crashing/restarting daemon could also be re-triggering GUI unlock prompts each time. I can't confirm from the report alone whether the process truly never returns or whether it was still inside these windows when the reporter gave up; a maintainer may want to ask whether the hang exceeded ~1-2 minutes, and whether strace/gdbus monitor output is available to see which D-Bus call stalls.

    Generated by Issue Triage (skills-driven) for #14812 · copilot · auto · 133.2 AIC · ⊞ 4.5K · ◷

  2. ye-discernis commented on Oct 24, 2026

    @ye-discernis
    Author

    Answers, plus a controlled repro with strace.

    Controlled repro: keyring paused, not crashed

    I SIGSTOPed the single, healthy systemd-managed gnome-keyring-daemon, ran gh auth status under strace -f -tt -e trace=%process,%network,poll,ppoll,epoll_pwait,futex, then SIGCONTed it. gh 2.103.1.

    • gh auth status blocked for 180.2 s, exactly 3 × 60 s. The trace shows three back-to-back waits, each timing out at 60 s:
      futex(..., FUTEX_WAIT_PRIVATE, 0, {tv_sec=59, tv_nsec=988072314}) = -1 ETIMEDOUT
      futex(..., FUTEX_WAIT_PRIVATE, 0, {tv_sec=59, tv_nsec=997269552}) = -1 ETIMEDOUT
      futex(..., FUTEX_WAIT_PRIVATE, 0, {tv_sec=59, tv_nsec=990220917}) = -1 ETIMEDOUT
      
      The session-bus connect() happens at t=0. Nothing else happens until the third timeout, after which gh resolves DNS, connects to api.github.com:443 and exits 1.
      This confirms the triage hypothesis: sequential 60 s keyring timeouts (here three of them), with no progress indicator.
    • The final message is misleading. After the timeouts, gh prints:
      X Failed to log in to github.com account <me> (default)
      - The token in default is invalid.
      - To re-authenticate, run: gh auth login -h github.com
      
      The token was never read, because the keyring didn't answer. A keyring timeout is being reported as an invalid token, which sends the user to gh auth login. That command then hits the same keyring and hangs again. In the real incident, that is exactly the loop I ended up in.

    The original incident (system journal, local time)

    • 22:37:26: the long-running gnome-keyring-daemon logged gkd_secret_service_get_pkcs11_session: assertion 'client' failed, aes_negotiate: assertion 'session' failed, and g_variant_new: expected GVariant of type 'v' but received value has type '(null)', then aborted (SIGABRT, 22:37:28).
    • In the same second, the session bus logged Activating service name='org.freedesktop.secrets' requested by ... comm="gh auth token". That started the D-Bus-activation copy (--start --components=secrets) alongside the systemd unit, which systemd restarted at 22:37:29. Both copies then logged "The Secret Service was already initialized", and the D-Bus copy logged discover_other_daemon: 1.
    • Durations with two daemons: gh auth login -h github.com -p ssh -w blocked for about 18 minutes (exit 1, no device code ever printed). gh auth status blocked for about 3 minutes, consistent with the 3 × 60 s above.

    Suggestions

    1. Distinguish "keyring timed out or unavailable" from "token invalid", with a hint (unlock or repair the keyring, or --insecure-storage).
    2. Print progress while waiting on the keyring (e.g. "waiting for system keyring…").
    3. After the first keyring timeout in a single invocation, skip the remaining keyring calls instead of paying 60 s for each.
  3. hlymhalsyry48-hash commented on Oct 24, 2026

    @hlymhalsyry48-hash
  4. added
    bug
    priority-3
    gh-auth
    on Nov 9, 2026
  5. removed
    needs-triage
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggh-authpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions