fix(meta): set heartbeat for Muse STT websocket - #2523
Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
Open
rosetta-livekit-bot[bot] wants to merge 1 commit into
rosetta-livekit-bot[bot] wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: b55d0f5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 39 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports livekit/agents#7315 to the Meta Muse STT plugin.
Adds a 30-second websocket heartbeat with a pong deadline so half-open connections surface through the existing retry/error path instead of stalling indefinitely.
Verification
pnpm test plugins/meta(49 passed)pnpm build(40 packages built)pnpm --filter @livekit/agents-plugin-meta typecheckpnpm exec prettier --check plugins/meta/src/stt.ts .changeset/meta-muse-websocket-heartbeat.mdpnpm lintattempted; repository-wide lint currently fails on pre-existing formatting errors across 45 files. The only Meta-package failure is the unchanged union declaration atplugins/meta/src/stt.test.ts:36; changed lines pass lint/format checks.Source diff coverage
livekit-plugins/livekit-plugins-meta/livekit/plugins/meta/stt.py: adapted toplugins/meta/src/stt.ts. Python aiohttp accepts a heartbeat in seconds; the JSwsclient has no native equivalent, so this ports30.0seconds as30_000ms and adds ping/pong timeout lifecycle infrastructure while preserving the existing retry/error path.tests/test_meta_stt.py: adapted toplugins/meta/src/stt.test.ts. Added the source assertion’s equivalent to the existing Muse handshake/connection contract test, verifying the factory receives the 30-second heartbeat value.Ported from livekit/agents#7315
Original PR description
_connect_wsopened the WebSocket without aheartbeat, so nothing probedthe connection. A silently dropped socket (half-open TCP, no FIN/RST — routine
behind NAT idle timeouts and load balancers) left
_receive_eventsparked onws.receive()forever: recovery here is exception-driven, so with no exceptionthere was no reconnect.
conn_options.timeoutdoesn't cover this — it guardsonly the handshake and the post-
end_inputdrain, not steady streaming.Detection fell back to TCP retransmit exhaustion: ~15 min with default
tcp_retries2=15while audio flows, and never while audio is idle(mic disabled/unpublished), since there are no writes to fail.
Sets
heartbeat=30.0, matching Deepgram (deepgram/stt.py:797,stt_v2.py:628)and the repo-wide convention. No new handling needed: an aiohttp heartbeat
timeout surfaces as
WSMsgType.ERROR, which_receive_eventsalready turns intoAPIConnectionError(retryable=not self._audio_consumed)— a reconnect beforeaudio is consumed, and a fast session-level failure after, instead of a
multi-minute stall.
Test:
test_handshake_precedes_audio_and_matches_contractalready inspects thews_connectkwargs, so the assertion goes there.