Skip to content

StreamingTranscriber.connect() hangs indefinitely on failure #136

@mostafaroshdy1

Description

@mostafaroshdy1

Summary

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:

uncaughtException: Error: getaddrinfo ENOTFOUND streaming.assemblyai.com

Description

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:

  1. DNS/Transport Errors: If a ENOTFOUND or ECONNREFUSED occurs, onerror fires, but the Promise is never rejected.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions