fix(avatar): handle clear-buffer RPC failures#2045
Conversation
🦋 Changeset detectedLatest commit: 9d162b4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 37 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 |
toubatbrian
left a comment
There was a problem hiding this comment.
The regression test currently uses room as unknown as Room, which violates this repository's explicit no-typecast rule.
Please replace it with a real typed Room fixture and mock only the required fields. I verified that this test-only change preserves rejected clear-buffer RPC coverage and passes the focused test, formatting, lint, agents typecheck, and build:agents.
Preserve the clear call's segment boundary so delayed failures do not finish newer audio. Cover the failure behaviour with typed Room tests.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c913adfea
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Keep the three distinct regression behaviours while removing duplicate assertions and a single-use helper.
Problem
DataStreamAudioOutput.clearBuffer()startsLocalParticipant.performRpc()and discards the returned promise. If the remote avatar participant disconnects while interruption clean-up is running, the RPC can reject withFailed to send, producing a process-level unhandled rejection even though the session can continue.Solution
Treat the clear-buffer RPC as intentionally fire-and-forget and attach a rejection handler. Failed calls are reported through the existing logger with the destination identity, whilst the synchronous
clearBuffer(): voidcontract remains unchanged.This keeps interruption clean-up non-blocking and avoids changing callers for an RPC whose recipient may already be unavailable. A focussed regression test covers the rejected RPC path, and a patch changeset records the fix.
Verification
pnpm test -- agents/src/voice/avatar/datastream_io.test.tspnpm exec eslint -f unix agents/src/voice/avatar/datastream_io.ts agents/src/voice/avatar/datastream_io.test.tspnpm exec prettier --check agents/src/voice/avatar/datastream_io.ts agents/src/voice/avatar/datastream_io.test.ts .changeset/catch-avatar-clear-buffer-rpc.mdpnpm --filter @livekit/agents typecheckpnpm build:agents