From c0c7ea8828d71f5d6d88fa8fd6968b562c215cd1 Mon Sep 17 00:00:00 2001 From: Henrik Friedrichsen Date: Tue, 29 Aug 2023 21:47:07 +0200 Subject: [PATCH] Make worker command delivery more resilient This may discard commands during reauthentication, but at least it doesn't crash the application. May help with #993 and #1257 --- src/spotify.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spotify.rs b/src/spotify.rs index 88ac916..75a5a25 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -337,9 +337,17 @@ impl Spotify { } fn send_worker(&self, cmd: WorkerCommand) { + info!("sending command to worker: {:?}", cmd); let channel = self.channel.read().expect("can't readlock worker channel"); match channel.as_ref() { - Some(channel) => channel.send(cmd).expect("can't send message to worker"), + Some(channel) => { + if let Err(e) = channel.send(cmd) { + error!( + "can't send command to spotify worker: {}, dropping command", + e + ); + } + } None => error!("no channel to worker available"), } }