Zackriya-Solutions/meetily · warning · anyhow::Error
Failed to stop some streams
Error message
Failed to stop some streams: {:?} What it means
stop_streams collected at least one error while stopping the microphone and/or system stream (sys_stream.stop() failed). Recording is ending anyway; this error means cleanup may be incomplete - a stream and its resources may still be alive.
Solutions
- Treat cleanup as best-effort: log the errors and continue shutdown instead of propagating
- Make stop idempotent (guard against stopping the same stream twice)
- If a device vanished mid-session, expect this error and simply release the stream handles
Example fix
// before
if !errors.is_empty() {
Err(anyhow::anyhow!("Failed to stop some streams: {:?}", errors))
} else {
info!("All audio streams stopped successfully");
Ok(())
}
// after - cleanup is best-effort; report but never block shutdown
if !errors.is_empty() {
warn!("Failed to stop some streams (continuing): {:?}", errors);
}
info!("Stream shutdown complete");
Ok(()) Defensive patterns
Strategy: try-catch
Try / catch
// Cleanup must never block shutdown: collect, log, continue
let mut errs = Vec::new();
if let Some(s) = self.microphone_stream.take() {
if let Err(e) = s.stop() { errs.push(e); }
}
if let Some(s) = self.system_stream.take() {
if let Err(e) = s.stop() { errs.push(e); }
}
if !errs.is_empty() {
warn!("Stream stop errors (ignored): {errs:?}");
}
Ok(()) Prevention
- Make stop idempotent and tolerant of already-invalid streams
- Listen for device-removal events and stop streams proactively
- Do not treat stop failures as recording failures in user-facing logs
When it happens
Trigger: Stopping streams after the underlying device disappeared (Bluetooth off, USB unplugged) so the stream is already invalid; double-stop on some paths; coreaudiod restarted mid-recording.
Common situations: User ends recording right as a headset disconnects; stop_streams racing device removal during shutdown.
Related errors
- Buffer should always be available
- Cannot access microphone
- Cannot start microphone
- Device name cannot be empty
- Device not found
AI-assisted analysis of Zackriya-Solutions/meetily@a2cb62e827 (2026-08-16).
Data as JSON: /api/errors/796325cb1462f123.
Report an issue: GitHub.
Appendix: source
Thrown at frontend/src-tauri/src/audio/stream.rs:452
// Stop microphone stream
if let Some(mic_stream) = self.microphone_stream.take() {
if let Err(e) = mic_stream.stop() {
error!("Failed to stop microphone stream: {}", e);
errors.push(e);
}
}
// Stop system stream
if let Some(sys_stream) = self.system_stream.take() {
if let Err(e) = sys_stream.stop() {
error!("Failed to stop system stream: {}", e);
errors.push(e);
}
}
if !errors.is_empty() {
Err(anyhow::anyhow!("Failed to stop some streams: {:?}", errors))
} else {
info!("All audio streams stopped successfully");
Ok(())
}
}
/// Take the microphone stream OUT of the manager, keeping system audio
/// running. The caller stops/drops it OUTSIDE any lock — a cpal teardown
/// of a dead BT device can stall and must not block a held mutex.
pub fn take_mic_stream(&mut self) -> Option<AudioStream> {
self.microphone_stream.take()
}
/// Set a new microphone stream (used after hot-swap creation).
pub fn set_mic_stream(&mut self, stream: AudioStream) {
self.microphone_stream = Some(stream);
}
View on GitHub (pinned to a2cb62e827)