Skip to content

Conversation

@DTCurrie
Copy link
Member

@DTCurrie DTCurrie commented Oct 31, 2025

Event listeners for WebRTC connection state changes were not cleared during reconnections, causing handlers to accumulate with every reconnect. This resulted in old handlers firing on stale connections and potential race conditions due to duplicate event handling.

This PR implements event listener lifecycle management in RobotClient by adding class properties to store handler references (onICEConnectionStateChange, onDataChannelClose, onTrack), creating the cleanupEventListeners method to clear handler references, updating connect to call cleanup before registering new handlers, and updating disconnect to clean up handlers before closing connections.

It also introduces test coverage for client.ts, though the tests are currently limited just to event handling.

@DTCurrie DTCurrie self-assigned this Oct 31, 2025
@DTCurrie DTCurrie requested a review from a team as a code owner October 31, 2025 21:31
@DTCurrie DTCurrie requested review from njooma and stuqdog and removed request for a team October 31, 2025 21:31
@DTCurrie DTCurrie changed the title cleanup event handlers Cleanup event handlers on disconnect Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants