diff --git a/CHANGELOG.md b/CHANGELOG.md index 491d652c..b86ee735 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - daemon: Build the list of devices offered to the user from libwebauthn's `available_transports()`, the same source discovery uses (#32) - ui: Pass the caller's activation token to the compositor when showing the dialog, so it can take focus when the requesting window is in the background (#152) - ui: Disable core dumps for the UI process, which handles typed PINs. Build with `-Denable_core_dumps=true` to allow them for debugging (#209) +- ui: Don't crash when a request ends while the UI is still sending it events, e.g. because the caller disconnected right after starting it # 0.4.0 [2026-11-05] diff --git a/credentialsd-ui/src/gui/view_model/gtk/mod.rs b/credentialsd-ui/src/gui/view_model/gtk/mod.rs index f2b7d305..b279d90f 100644 --- a/credentialsd-ui/src/gui/view_model/gtk/mod.rs +++ b/credentialsd-ui/src/gui/view_model/gtk/mod.rs @@ -14,7 +14,7 @@ use gtk::glib::{self, Bytes}; use gtk::prelude::*; use gtk::subclass::prelude::*; use qrcode::QrCode; -use tracing::debug; +use tracing::{debug, warn}; use crate::config::{GETTEXT_PACKAGE, LOCALEDIR, RESOURCES_FILE}; use application::CredentialsUi; @@ -118,7 +118,9 @@ impl ViewModel { { let tx = view_model.imp().tx.borrow(); let tx = tx.as_ref().expect("tx to exist"); - tx.send_blocking(ViewEvent::Initiated).unwrap(); + if tx.send_blocking(ViewEvent::Initiated).is_err() { + warn!("Request ended before the UI started"); + } } view_model @@ -325,7 +327,9 @@ impl ViewModel { let id = button.widget_name().to_string(); let tx = tx.clone(); glib::spawn_future_local(async move { - tx.send(ViewEvent::CredentialSelected(id)).await.unwrap(); + if tx.send(ViewEvent::CredentialSelected(id)).await.is_err() { + warn!("Request ended before the credential selection was handled"); + } }); }); button.into() @@ -387,7 +391,11 @@ impl ViewModel { async fn send_event(&self, event: ViewEvent) { let tx = self.get_sender(); - tx.send(event).await.unwrap(); + if tx.send(event).await.is_err() { + // The request's event loop has ended, e.g. because the caller + // went away; the UI closes with it. + warn!("Request ended before the UI event was handled"); + } } }