You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
URLError(.cancelled) is not recognized as cancellation in awaitUpload(), repainting cancelled dictations as .failed #324
In DictationSession+Pipeline.swift:awaitUpload, when an in-flight upload task throws on cancellation, the error is caught to avoid repainting a cancelled session as a failure:
do{returntryawaitinFlight.value}catch{
// A cancel() that landed mid-request already tore this task down and set
// .cancelled; the transport then surfaces a cancellation-shaped error
// (URLError(.cancelled) / CancellationError). Leave the claimed phase
// alone rather than repainting the user's cancel as a red failure.
ifTask.isCancelled||error is CancellationError{returnnil}...ifletblurtError=erroras?BlurtError{setPhase(.failed(blurtError))}else{setPhase(.failed(.sttFailed(underlying:error)))}returnnil}
The comment explicitly notes the expected cancellation errors: (URLError(.cancelled) / CancellationError).
However, the condition only checks Task.isCancelled || error is CancellationError. In Swift, URLError is a distinct type conforming to Error and is not CancellationError (error is CancellationError evaluates to false).
When an upload request is cancelled via cancelUpload() / upload?.cancel(), cancelRecording(), or when URLSession aborts an in-flight streamed upload, the underlying transport throws URLError(.cancelled). If pipelineTask is awaiting inFlight.value and has not yet had its task cancellation flag set, Task.isCancelled evaluates to false.
As a result, URLError(.cancelled) falls through to:
setPhase(.failed(.sttFailed(underlying:error)))
which repaints the cancelled session as a red failure on the overlay and logs an erroneous failure to developer-mode logs via seams.logFailure(...).
In contrast, other cancellation catch sites in the codebase (e.g. SelectionSpeechRouter+Command.swift:121 and AssemblyAISpeechSynthesizer.swift:92) explicitly check (error as? URLError)?.code == .cancelled.
Expected behavior
When inFlight.value throws URLError(.cancelled), awaitUpload should recognize it as cancellation ((error as? URLError)?.code == .cancelled) and return nil, leaving the phase alone.
Activity