Events Being Dropped on Connection#122
Conversation
9b5a873 to
edaf730
Compare
cf3dcde to
f0b82a9
Compare
xianshijing-lk
left a comment
There was a problem hiding this comment.
lgtm.
can you search FfiClient::instance().AddListener() in our code base, and make sure we are using the same patter for all use cases ?
@xianshijing-lk : |
597f291 to
a3ee6a5
Compare
|
new unit tests shows that the race condition does still exist. We are going to move forward with a "ready" signal from the client sdk to the rust sdk which signals to rust that the client is ready for room events. see this slack thread for discussion: https://live-kit.slack.com/archives/C02EWQYP4KE/p1778708015361339?thread_ts=1778285077.084319&cid=C02EWQYP4KE |
cb5f648 to
451d4ad
Compare
451d4ad to
f519e5f
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses a connection-time race where room events can be dropped by registering the FFI event listener earlier in Room::Connect() and explicitly notifying the Rust core when the C++ room is ready to receive/flush room events. It also adds new integration/stress coverage focused on listener cleanup and late-join publication callbacks.
Changes:
- Register the FFI listener before
connectAsync()and send a newready_for_room_eventrequest after the room handle/state is fully initialized. - Add integration tests validating that failed/invalid connects and reconnect flows don’t leave duplicate listeners (no duplicate participant callbacks).
- Add integration/stress tests validating late-join publication/subscription callback ordering and a concurrent reconnect/publish stress scenario.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/room.cpp | Installs the FFI listener earlier and sends a “ready” request to flush room events once initialization completes; improves failure cleanup. |
| src/ffi_client.cpp | Minor formatting cleanup. |
| src/tests/stress/test_room_listener_race_stress.cpp | New stress test for concurrent failed connect/destroy/reconnect and data track publishing. |
| src/tests/integration/test_room_listener_cleanup.cpp | New integration tests to ensure failed/invalid connects don’t leak/duplicate listeners and callbacks. |
| src/tests/integration/test_late_join_track_publication.cpp | New parameterized integration tests validating late-join publication/subscription callback invariants for audio/video/data tracks. |
| AGENTS.md | Adds guidance about not updating generated code (spelling nit present). |
| .gitignore | Ignores user_stories. |
Comments suppressed due to low confidence (2)
src/tests/integration/test_room_listener_cleanup.cpp:115
- Tests should skip (GTEST_SKIP / skipIfNotConfigured) when LIVEKIT_* env vars are not set, rather than throwing. Throwing here will fail the entire integration test run in environments without credentials.
if (!config_.available) {
throw std::runtime_error("LIVEKIT_URL, LIVEKIT_TOKEN_A, and LIVEKIT_TOKEN_B not set");
}
src/tests/integration/test_room_listener_cleanup.cpp:123
- Tests should skip (GTEST_SKIP / skipIfNotConfigured) when LIVEKIT_* env vars are not set, rather than throwing. Throwing here will fail the entire integration test run in environments without credentials.
if (!config_.available) {
throw std::runtime_error("LIVEKIT_URL, LIVEKIT_TOKEN_A, and LIVEKIT_TOKEN_B not set");
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Overview
RoomReadyEventRequestwhich gets called after ffi handle is createdTesting