From 6be4fd221296b74a92b12b953a8c80331360f573 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 4 Apr 2026 13:27:44 +0000 Subject: [PATCH] Skip error recovery on intentional cancellation (#477) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When SlidingWindowAsrManager is cancelled, CancellationError propagates through processWindow() and the audio buffer loop. Previously this triggered attemptErrorRecovery() which resets the decoder and, as a last resort, re-downloads models — neither of which is appropriate for an intentional shutdown. Guard both catch sites with `error is CancellationError || Task.isCancelled` to return immediately instead. Fixes #477 https://claude.ai/code/session_01696MyMtoiM6T8ruCdCCHab --- .../Parakeet/SlidingWindow/SlidingWindowAsrManager.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/FluidAudio/ASR/Parakeet/SlidingWindow/SlidingWindowAsrManager.swift b/Sources/FluidAudio/ASR/Parakeet/SlidingWindow/SlidingWindowAsrManager.swift index 27e86d119..cfeb93013 100644 --- a/Sources/FluidAudio/ASR/Parakeet/SlidingWindow/SlidingWindowAsrManager.swift +++ b/Sources/FluidAudio/ASR/Parakeet/SlidingWindow/SlidingWindowAsrManager.swift @@ -159,6 +159,9 @@ public actor SlidingWindowAsrManager { // Append to raw sample buffer and attempt windowed processing await self.appendSamplesAndProcess(samples) } catch { + if error is CancellationError || Task.isCancelled { + return + } let streamingError = SlidingWindowAsrError.audioBufferProcessingFailed(error) logger.error( "Audio buffer processing error: \(streamingError.localizedDescription)") @@ -470,6 +473,9 @@ public actor SlidingWindowAsrManager { updateContinuation?.yield(update) } catch { + if error is CancellationError || Task.isCancelled { + return + } let streamingError = SlidingWindowAsrError.modelProcessingFailed(error) logger.error("Model processing error: \(streamingError.localizedDescription)")