{"record":{"id":"796325cb1462f123","repo":"Zackriya-Solutions/meetily","slug":"failed-to-stop-some-streams","errorCode":null,"errorMessage":"Failed to stop some streams: {:?}","messagePattern":"Failed to stop some streams: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"frontend/src-tauri/src/audio/stream.rs","lineNumber":452,"sourceCode":"\n        // Stop microphone stream\n        if let Some(mic_stream) = self.microphone_stream.take() {\n            if let Err(e) = mic_stream.stop() {\n                error!(\"Failed to stop microphone stream: {}\", e);\n                errors.push(e);\n            }\n        }\n\n        // Stop system stream\n        if let Some(sys_stream) = self.system_stream.take() {\n            if let Err(e) = sys_stream.stop() {\n                error!(\"Failed to stop system stream: {}\", e);\n                errors.push(e);\n            }\n        }\n\n        if !errors.is_empty() {\n            Err(anyhow::anyhow!(\"Failed to stop some streams: {:?}\", errors))\n        } else {\n            info!(\"All audio streams stopped successfully\");\n            Ok(())\n        }\n    }\n\n    /// Get stream count\n    pub fn active_stream_count(&self) -> usize {\n        let mut count = 0;\n        if self.microphone_stream.is_some() {\n            count += 1;\n        }\n        if self.system_stream.is_some() {\n            count += 1;\n        }\n        count\n    }\n","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/Zackriya-Solutions/meetily/blob/0281737d87d26352fb0adc78c8c0975f691b23d1/frontend/src-tauri/src/audio/stream.rs#L434-L470","documentation":"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.","triggerScenarios":"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.","commonSituations":"User ends recording right as a headset disconnects; stop_streams racing device removal during shutdown.","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"],"exampleFix":"// before\nif !errors.is_empty() {\n    Err(anyhow::anyhow!(\"Failed to stop some streams: {:?}\", errors))\n} else {\n    info!(\"All audio streams stopped successfully\");\n    Ok(())\n}\n\n// after - cleanup is best-effort; report but never block shutdown\nif !errors.is_empty() {\n    warn!(\"Failed to stop some streams (continuing): {:?}\", errors);\n}\ninfo!(\"Stream shutdown complete\");\nOk(())","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Cleanup must never block shutdown: collect, log, continue\nlet mut errs = Vec::new();\nif let Some(s) = self.microphone_stream.take() {\n    if let Err(e) = s.stop() { errs.push(e); }\n}\nif let Some(s) = self.system_stream.take() {\n    if let Err(e) = s.stop() { errs.push(e); }\n}\nif !errs.is_empty() {\n    warn!(\"Stream stop errors (ignored): {errs:?}\");\n}\nOk(())","preventionTips":["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"],"tags":["audio","cleanup","stream-stop","device-removal"],"backgroundTag":"audio-stream-cleanup-failed","analyzedSha":"0281737d87d26352fb0adc78c8c0975f691b23d1","analyzedAt":"2026-08-16T20:57:52.567Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}