From 68e154aa08315395e0661fe5269d1d0c7201e07c Mon Sep 17 00:00:00 2001 From: psykose Date: Tue, 19 Nov 2024 18:25:25 +0100 Subject: [PATCH] fix crash when future cancelled --- meson.build | 4 +++- src/subsonic.rs | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index e451eb3..5a8df45 100644 --- a/meson.build +++ b/meson.build @@ -51,7 +51,9 @@ cargo_env = environment() cargo_env.set('MESON_BUILD_ROOT', meson.project_build_root()) cargo_env.set('CARGO_MANIFEST_DIR', meson.project_source_root()) cargo_env.set('CARGO_TARGET_DIR', meson.project_build_root() / 'target') -meson.add_devenv(cargo_env) +dev_env = cargo_env +dev_env.set('RUST_BACKTRACE', 'full') +meson.add_devenv(dev_env) custom_target( 'cargo-build', diff --git a/src/subsonic.rs b/src/subsonic.rs index 878ea47..6f5b66a 100644 --- a/src/subsonic.rs +++ b/src/subsonic.rs @@ -204,16 +204,17 @@ impl Client { }) } - sender - .send(perform(future.await).await) - .await - .expect("could not send subsonic response back to the main loop"); + sender.send(perform(future.await).await).await.map_err(|_| { + Error::OtherError( + "failed to send back response from tokio request (future probably cancelled)", + ) + }) }); receiver .recv() .await - .expect("could not receive subsonic response from tokio") + .map_err(|_| Error::OtherError("failed to receive response from tokio loop"))? } fn url(&self, path: &[&str], query: &[(&str, &str)]) -> url::Url {