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.

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(())
        }
    }

    /// Get stream count
    pub fn active_stream_count(&self) -> usize {
        let mut count = 0;
        if self.microphone_stream.is_some() {
            count += 1;
        }
        if self.system_stream.is_some() {
            count += 1;
        }
        count
    }

View on GitHub (pinned to 0281737d87)

Solutions

  1. Treat cleanup as best-effort: log the errors and continue shutdown instead of propagating
  2. Make stop idempotent (guard against stopping the same stream twice)
  3. 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

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


AI-assisted analysis of Zackriya-Solutions/meetily@0281737d87 (2026-08-16). Data as JSON: /api/errors/796325cb1462f123. Report an issue: GitHub.