Repository navigation
daemon: Cancel a request when its caller disconnects - #278
Merged
Merged
Conversation
With linux-credentials#246, a client can cancel a request explicitly with Close(), but a request whose caller leaves the bus unexpectedly, e.g. because it crashed, stays open until the user dismisses the UI. Watch the caller's unique name for the duration of the ceremony and cancel the request once it has no owner. NameHasOwner is checked after subscribing to NameOwnerChanged, so a caller that left before the watch was set up is caught too. This works with and without a request handle. If setting up the watch fails, the request goes on as before. In the portal setup the caller is xdg-desktop-portal, which already closes the handler request when the app that made it goes away. This covers the portal itself going away, and callers that talk to the daemon directly. Fixes linux-credentials#274
iinuwa
approved these changes
Nov 20, 2026
iinuwa
left a comment
Member
There was a problem hiding this comment.
I was literally writing the same thing last night!
iinuwa
reviewed
Nov 20, 2026
| }, | ||
| None => None, | ||
| }; | ||
|
|
Member
There was a problem hiding this comment.
merging for now, but this can be simplified: we don't support P2P connections, and we rely on the bus, so there will always be a sender. returning an error on an empty sender would flatten this.
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.
Fixes #274.
#246 lets a client cancel a request with
Close(), but a request whose caller leaves the bus unexpectedly, e.g. because it crashed, stays open until the user dismisses the UI.run_ceremonynow watches the caller's unique name for as long as the ceremony runs and cancels the request once the name has no owner:NameOwnerChangedfor the caller and then checksNameHasOwner, so a caller that left before the watch was set up is caught too.Close().Scope
In the portal setup the daemon's caller is xdg-desktop-portal, not the app. When the app goes away, the portal already closes the handler request (linux-credentials/xdg-desktop-portal#1 →
Close()from #246). So this change covers:It does not cancel a request when Firefox crashes; see below.
Testing
Cancelled. They fail with a timeout when the watch is disabled.kill -9during a create request: the daemon logged "Caller left the bus" 12 ms later, cancelled the request and the UI closed.Close()and the request was cancelled. This is the existing daemon: Allow clients to cancel requests #246 path, and it still works.Found while testing: a Firefox crash still leaves the request open
When Firefox is killed mid-request, the native helper (
webext/app/credential_manager_shim.py) keeps running. It waits on the portal call and doesn't notice that Firefox has gone, so the request and dialog stay open until the helper's own 5-minute timeout. 45 s after the kill the helper was still running. That needs a fix in the helper, for example watching stdin for EOF, and is not part of this PR. I can open an issue for it.