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
StreamingTranscriber.connect() hangs indefinitely on failure #136
I encountered this issue in a high-traffic production environment during a period of DNS instability. When a DNS resolution failed, the process crashed with the following error, but because the connection Promise never rejected, the application was unable to catch or handle the exception gracefully:
The current implementation of StreamingTranscriber.connect() returns a Promise that only settles (resolves) upon receiving a Begin message. If the connection fails before this message arrives, the Promise remains pending indefinitely.
This creates a "black hole" in the application logic where await transcriber.connect() never completes, making it impossible to handle network issues using standard try/catch blocks or automated retry logic.
The Problem
There are some scenarios where the Promise currently hangs:
DNS/Transport Errors: If a ENOTFOUND or ECONNREFUSED occurs, onerror fires, but the Promise is never rejected.
Premature Closure: If the server drops the connection (e.g., a 4xx/5xx proxy error) before the Begin event, onclose fires, but the Promise stays pending.
dug into this one - good news: this exact failure mode was fixed in 4.35.0 (june 16, 2026). before that, connect()'s promise executor only captured resolve - onclose and onerror fired the listeners but could never reject, so a dns failure or a pre-Begin close left await transcriber.connect() pending forever. in 4.35.0 connect() was reworked into a connectOnce() attempt with a settled flag: a pre-Begin close now rejects with a StreamingError carrying the close code, a pre-Begin error rejects as retryable, and connect() retries transient failures up to maxConnectionRetries (default 2) with connectionRetryDelay between attempts, while permanent failures like auth reject immediately. upgrade to >=4.35.0 and your try/catch and retry logic will work the way you expected. this one's probably safe to close.
Built by breken, your AI support engineer - breken.ai finds the bug, proves the fix with unmatched RCA, answers customers in your voice, and keeps your code and support docs clean - this one's on us.
Activity
breken-ai commentedon Sep 9, 2026
dug into this one - good news: this exact failure mode was fixed in 4.35.0 (june 16, 2026). before that, connect()'s promise executor only captured resolve - onclose and onerror fired the listeners but could never reject, so a dns failure or a pre-Begin close left
await transcriber.connect()pending forever. in 4.35.0 connect() was reworked into a connectOnce() attempt with a settled flag: a pre-Begin close now rejects with a StreamingError carrying the close code, a pre-Begin error rejects as retryable, and connect() retries transient failures up to maxConnectionRetries (default 2) with connectionRetryDelay between attempts, while permanent failures like auth reject immediately. upgrade to >=4.35.0 and your try/catch and retry logic will work the way you expected. this one's probably safe to close.Built by breken, your AI support engineer - breken.ai finds the bug, proves the fix with unmatched RCA, answers customers in your voice, and keeps your code and support docs clean - this one's on us.
fix(realtime): tear down socket on connection failure and remove issu…
fix(realtime): reject connect() promise when WebSocket errors before …
fix(realtime): tear down socket on connection failure and remove issu…