Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: handle closed channel in audio stream error callback (#2674)

Onyeka Obi0fab317c1790
diff --git a/crates/screenpipe-audio/src/core/stream.rs b/crates/screenpipe-audio/src/core/stream.rs
index e55297619..d5fe12206 100644
--- a/crates/screenpipe-audio/src/core/stream.rs
+++ b/crates/screenpipe-audio/src/core/stream.rs
@@ -230,9 +230,15 @@ fn create_error_callback(
"audio device {} disconnected. stopping recording.",
device_name
);
- stream_control_tx
+ if stream_control_tx
.send(StreamControl::Stop(oneshot::channel().0))
- .unwrap();
+ .is_err()
+ {
+ warn!(
+ "stream control channel closed for {}, stream already stopping",
+ device_name
+ );
+ }
is_disconnected.store(true, Ordering::Relaxed);
} else {
error!("an error occurred on the audio stream: {}", err);