Skip to content

Commit 6be4fd2

Browse files
committed
Skip error recovery on intentional cancellation (#477)
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
1 parent 6c40eca commit 6be4fd2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Sources/FluidAudio/ASR/Parakeet/SlidingWindow/SlidingWindowAsrManager.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ public actor SlidingWindowAsrManager {
159159
// Append to raw sample buffer and attempt windowed processing
160160
await self.appendSamplesAndProcess(samples)
161161
} catch {
162+
if error is CancellationError || Task.isCancelled {
163+
return
164+
}
162165
let streamingError = SlidingWindowAsrError.audioBufferProcessingFailed(error)
163166
logger.error(
164167
"Audio buffer processing error: \(streamingError.localizedDescription)")
@@ -470,6 +473,9 @@ public actor SlidingWindowAsrManager {
470473
updateContinuation?.yield(update)
471474

472475
} catch {
476+
if error is CancellationError || Task.isCancelled {
477+
return
478+
}
473479
let streamingError = SlidingWindowAsrError.modelProcessingFailed(error)
474480
logger.error("Model processing error: \(streamingError.localizedDescription)")
475481

0 commit comments

Comments
 (0)