Skip to content

fix: lazy-load text-to-speech websocket peer#407

Open
alceops wants to merge 1 commit into
team-telnyx:masterfrom
alceops:alce/lazy-load-tts-ws-406
Open

fix: lazy-load text-to-speech websocket peer#407
alceops wants to merge 1 commit into
team-telnyx:masterfrom
alceops:alce/lazy-load-tts-ws-406

Conversation

@alceops

@alceops alceops commented May 8, 2026

Copy link
Copy Markdown

Fixes #406.

This keeps the ws peer dependency optional for normal SDK imports by changing the Text-to-Speech websocket wrapper to import ws only as a type and require the runtime package when TextToSpeechWS is actually constructed. If ws is missing at that point, the constructor now throws a targeted optional-peer error instead of making import telnyx fail for every consumer.

I also added a regression test that mocks ws as unavailable and verifies:

  • require('telnyx') still succeeds without ws on disk
  • constructing TextToSpeechWS is the point where the missing optional peer error is raised

Verification in this environment:

  • git diff --check
  • static assertions that the top-level value import was removed and the runtime require('ws') is deferred

I could not run the Jest suite locally because this cron runtime does not have Node/npm/pnpm installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

telnyx SDK eagerly requires ws (declared optional peer) — breaks telnyx-mcp and any consumer that doesn't pre-install ws

1 participant