Conversation
A single failed GET /voice/calls/:id poll ended the call immediately, even for a short network flap the peer would have recovered from. Track consecutive poll failures on the session and only declare the control connection lost after three in a row; any successful poll resets the count. Mirrors the grace period CopilotKit#26 gives the peer connection. Adds regression tests covering the new behavior. Fixes CopilotKit#38
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.
What
useVoicepollsGET /voice/calls/:idevery 2 seconds. The.catch()on that poll setCall control connection was lost.and ended the call on the first failure, so a short network flap hung up a call the peer would have recovered from. #26 adds a five-second grace period forRTCPeerConnectiondisconnectedbut does not cover this path.Changes
src/client/useVoice.ts: count consecutive control-poll failures on the session. The call ends after three in a row; a successful poll resets the count. Same idea as the grace period in fix: allow voice connections five seconds to recover #26.tests/use-voice-control-poll.test.ts: regression tests with a mocked peer, media, and API. One failed poll keeps the call alive, a later success resets the count, and three consecutive failures end the call exactly once withCall control connection was lost.react-test-rendererand its types as dev dependencies for the hook tests, same as fix: allow voice connections five seconds to recover #26.Tradeoff
If the server is really gone, the call now stays up for about six more seconds before ending. The design question in #38 is still open, so say the word if you want a different threshold or one window shared with the peer state.
Tests
New tests fail on the base commit (2 failed, 2 passed) and pass with the change (4 passed). Full suite: 166/168 pass; the 2 failures are
tests/transport.test.ts(DNS-pinned transport needs live network) and fail on the base commit too.npm run check-format,npm run lint,npm run typecheck, andnpm run buildall pass.Fixes #38