Skip to content

[Fix] 170-electron-live-transcription-node — migrate to SDK v5 connect() API#110

Merged
lukeocodes merged 2 commits into
mainfrom
fix/170-electron-live-transcription-node-regression-2026-04-02
Apr 2, 2026
Merged

[Fix] 170-electron-live-transcription-node — migrate to SDK v5 connect() API#110
lukeocodes merged 2 commits into
mainfrom
fix/170-electron-live-transcription-node-regression-2026-04-02

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot commented Apr 2, 2026

Summary

  • Replaced deprecated listen.v1.live() with await listen.v1.connect() + connection.connect() / waitForOpen()
  • Replaced connection.send() with connection.sendBinary()
  • Replaced connection.finish() with connection.sendCloseStream() + connection.close()
  • Removed unnecessary JSON.parse() in message handler — SDK v5 delivers pre-parsed objects

Root cause

The @deepgram/sdk package (^5.0.0) dropped the .live() method from listen.v1, causing a runtime TypeError. The current API uses .connect() which returns a Promise<WrappedListenV1Socket>.

Test plan

  • node --check passes on all modified source files
  • npm test passes with valid DEEPGRAM_API_KEY (exits code 2 without credentials as expected)
  • CI integration test confirms live transcription works end-to-end

🤖 Generated with Claude Code

The SDK removed `.live()` in favor of `await .connect()`, `.sendBinary()`
replaces `.send()`, and `.close()` replaces `.finish()`. Message event
data is now pre-parsed (no JSON.parse needed).

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added the type:fix Fix to existing example label Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Apr 2, 2026

Code Review

Overall: CHANGES REQUESTED

Tests ran ❌

File structure check passed
electron package resolves to: .../node_modules/electron/index.js
All Electron source files pass syntax check
main.js uses expected Electron APIs: BrowserWindow, ipcMain, Tray, Menu, globalShortcut, nativeImage
preload.js uses contextBridge and ipcRenderer correctly
Electron security settings verified (contextIsolation, nodeIntegration)
Electron integration validation passed
Downloading test audio...
Audio ready: 829866 bytes of linear16 16 kHz
[deepgram] Connected — streaming audio...
[interim] Yeah. Is
[interim] Yeah. As as much as,
[final] Yeah. As as much as, it's worth
[interim] celebrating,
[interim] celebrating, the
[deepgram] Audio sent — waiting for final results...

Test failed: Transcripts arrived but no expected words found.
Got: Yeah. Is | Yeah. As as much as, | Yeah. As as much as, it's worth

The Deepgram connection worked and transcripts were received, but the word-matching assertion failed — none of the expected words (spacewalk, astronaut, nasa) appeared in the received transcripts.

Root cause: tests/test.js line 165-166 has a bug — connection.waitForOpen() is not awaited inside the new Promise() constructor:

connection.connect();
connection.waitForOpen();  // ← missing await, fire-and-forget

This means audio streaming may begin via the 'open' event before the WebSocket is truly ready, or timing is off causing early close before all final transcripts arrive. Compare with src/main.js:107-108 where await dgConnection.waitForOpen() is correctly used.

Integration genuineness

✅ Pass

  • @deepgram/sdk DeepgramClient imported and used for real live STT
  • listen.v1.connect() makes a real WebSocket connection to Deepgram
  • .env.example lists DEEPGRAM_API_KEY
  • Test exits code 2 when credentials are missing

Code quality

src/main.js — SDK migration looks correct:

  • listen.v1.live()listen.v1.connect() (async) ✓
  • connection.send()connection.sendBinary()
  • connection.finish()connection.sendCloseStream() + connection.close()
  • Removed unnecessary JSON.parse() (SDK v5 pre-parses) ✓
  • await dgConnection.waitForOpen() correctly awaited ✓
  • Credential check at top of file before SDK usage ✓
  • No hardcoded credentials ✓

tests/test.js line 165-166: connection.waitForOpen() not awaited — causes test failure

Documentation

⚠️ README.md line 47 still references the old API: client.listen.v1.live() — should be updated to client.listen.v1.connect() to match the migrated code.


Please address the items above:

  1. Fix tests/test.js to properly await waitForOpen() before the 'open' event fires
  2. Update README.md line 47 to reference connect() instead of live()

The fix agent will pick this up.


Review by Lead on 2026-04-02

@github-actions github-actions Bot added the status:fix-needed Tests failing — fix agent queued label Apr 2, 2026
… 170-electron-live-transcription-node

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Apr 2, 2026

Fix applied

Root cause: connection.waitForOpen() was not awaited in tests/test.js, causing a race condition where audio streaming could begin before the WebSocket connection was fully established, resulting in lost transcripts and no expected words being found.

Change: Replaced the open event listener with connection.waitForOpen().then(...) to properly await the connection before streaming audio, and updated README.md line 47 to reference the correct connect() API instead of the old live() method.

The lead reviewer will re-run tests and review on the next sweep.


Fix by Lead on 2026-04-02

@github-actions github-actions Bot removed the status:fix-needed Tests failing — fix agent queued label Apr 2, 2026
@lukeocodes lukeocodes merged commit 9da5ce2 into main Apr 2, 2026
@lukeocodes lukeocodes deleted the fix/170-electron-live-transcription-node-regression-2026-04-02 branch April 2, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:fix Fix to existing example

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant