Repository navigation
fix(connection): start without a keyring, and stop cancelled connects leaking - #527
Merged
Merged
Conversation
… leaking Two ways a connection could go wrong that the app handled badly. Keyring initialisation called .expect() on every platform, so a locked GNOME Keyring, a Flatpak sandbox with no Secret Service, or a headless session took the app down before it drew a window. The plaintext-password migration ran from ConnectionStore::new, whose caller also .expect()s, so anyone with a saved profile and a broken keyring could not launch at all. A missing credential store is a degraded mode, not a fatal one. Startup now logs a warning and carries on: profiles work, passwords simply are not remembered between sessions, and the status bar says so rather than leaving the user to discover it at the next launch. The migration skips a profile it cannot move and leaves the plaintext row in place so a later launch can retry, instead of failing construction. Nothing needed to change for the degraded path itself — keyring-core already answers NoDefaultStore as an error rather than panicking, so every password operation fails cleanly. The other is the Cancel-during-connect race. Disconnect issued before connect resolved found nothing to remove, and the connection was then added by the resolving connect — leaving a live pool on the server with nothing on this side able to close it, until the app restarted. Disconnect now records the intent when the id is not yet known, and a connect that lands on a cancelled id closes it on the server rather than merely dropping the reference. It also no longer calls the backend for an id this side does not have, which used to produce a "not found" error for what is an ordinary cancel. The existing test asserted the leak as the contract — "Documenting current behavior: connect wins" — so it now asserts the connection is closed instead. Moving the pending-cancel set into store state rather than a module variable was not cosmetic: as a module variable it leaked between tests and broke an unrelated disconnect-error case, which is a fair sign it would have leaked between windows too. Refs #278, #280
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #278, #280.
The app would not start without a keyring (#278)
init_keyringcalled.expect()on every platform, so a locked GNOME Keyring, a Flatpak sandbox with no Secret Service, or a headless session took the app down before it drew a window. Worse, the plaintext-password migration runs fromConnectionStore::new, whose caller also.expect()s — so anyone with a saved profile and a broken keyring could not launch at all.A missing credential store is a degraded mode, not a fatal one:
Passwords not saved, so the user learns it now rather than at the next launchNothing was needed for the degraded path itself:
keyring-corealready returnsNoDefaultStoreas an error rather than panicking, so every password operation fails cleanly once no store is attached.Cancel during connect leaked a server-side pool (#280)
Disconnect issued before connect resolved found nothing to remove; the resolving connect then added the entry. End state: a live pool on the server that nothing on this side can close, until the app restarts.
The existing test asserted the leak as the contract:
It now asserts the connection is closed instead.
One note on the fix
I first held the pending-cancel set in a module variable. It leaked between tests and broke an unrelated
handles disconnect errorcase — a fair sign it would leak between windows too, so it lives in store state. That existing test also needed a seeded connection, since the backend is now only asked about connections this side knows about.1656 frontend tests, 77 unit, 63 integration. clippy/tsc/dprint clean.
🤖 Generated with Claude Code