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
Realtime & Dictation streaming bugs: RealtimeTranscriber lifecycle/over-1000ms finish()/URLSession leak, stale turns abort, and ChunkedRequestBody / 413 fallback bugs #343
Four verified bugs in the Realtime recording and Dictation streaming transport layers:
RealtimeTranscriber lifecycle races, unchunked finish(), and URLSession leak (Sources/AssemblyAI/Realtime/RealtimeTranscriber.swift:56,62-119,137-142,182-190)
No isClosed state: if cancel() or finish() reaches the actor before start() (unstructured tasks in TranscriptsModel+Recording.swift:42,112,123), close() invalidates session and start() subsequently calls session.webSocketTask(with:) on an invalidated URLSession.
send(_ pcm:) appends to pendingbeforeguard task != nil, growing pending unboundedly after close().
start() does not drain pre-start pending, and finish() transmits pending in a single .data(tail) frame without chunking to maximumChunkBytes (32,000 B = 1000 ms), violating AssemblyAI v3's 1000 ms frame ceiling (and can send an odd byte count).
Concurrent finish() calls overwrite the single terminated continuation slot (leaking the first). Missing deinit leaks session when recorder.start throws in TranscriptsModel+Recording.swift:31-37.
TranscriptsModel.liveTranscriptionFailed leaks WebSocket and allows stale turns task to abort a later recording (App/Blurt/Blurt/Wizard/TranscriptsModel+Recording.swift:42-52,88-94,151-155)
When recorder.resume() throws, liveTranscriptionFailed never cancels recording.turns or recording.realtime. turns has no recording-URL guard (unlike watchForQuiet), so when Recording Import Blurt macOS dictation app #1's leaked socket later disconnects, its catch calls liveTranscriptionFailed and aborts Recording ci: harden checkout + finish Node 24 action bump #2.
ChunkedRequestBody.send masks or swallows AssemblyAIError.audioTooShort (Sources/AssemblyAI/ChunkedRequestBody.swift:85-91,171-205)
When streamedBody throws audioTooShort (AssemblyAITranscriber.swift:231-234), pipe.drain exits via defer { output.close() }, sending clean EOF instead of aborting fetch. If fetch throws URLError, lines 199-204 never run (flashing an error pill on a stray tap); if the server returns 200 OK, line 201 (!(200..<300)) swallows audioTooShort.
413 audio_too_large live-cap fallback duplicates up to 18 min of PCM in an unbounded buffer (Sources/BlurtEngine/STT/AssemblyAITranscriber.swift:149-168,211-240)
let body lives in transcribe()'s outer scope and liveFeed is not finished on LiveCapExceeded. When pipe.drain exits mid-write (bodyStreamClosed/cancel), body's onTermination does not fire until transcribe() returns, so streamedBody's producer keeps copying all post-120 s audio into body's unbounded buffer (~3x RAM).
(Minor)AssemblyAITranscriber.makeConfigData (line 274) re-reads rewriteMode() instead of using its mode parameter.
Suggested Fix
Add explicit State + deinit + chunked drainPending + waiter array to RealtimeTranscriber; cancel turns/realtime and guard turns by recording.url in TranscriptsModel+Recording.
Cancel fetch on producer failure in ChunkedRequestBody.send; scope body inside do and call liveFeed.finish() immediately on LiveCapExceeded.
Activity