Skip to content

Room disconnect issue fix#146

Draft
alan-george-lk wants to merge 6 commits into
mainfrom
feature/room_disconnect
Draft

Room disconnect issue fix#146
alan-george-lk wants to merge 6 commits into
mainfrom
feature/room_disconnect

Conversation

@alan-george-lk
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread include/livekit/room.h Outdated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

Comment thread src/ffi_client.h Outdated
Comment thread src/local_participant.cpp Outdated
msg->set_payload(*response_payload);
}
FfiClient::instance().sendRequest(req);
// This is invoked on the FFI listener thread; an unhandled throw here would
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FMU why is this being added here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a work around to avoid an integration test crash, I think this is a bad idea, still investigating

Comment thread src/room.cpp Outdated
Comment thread src/room.cpp Outdated
try {
FfiClient::instance().disconnectAsync(handle->get(), reason).get();
} catch (const std::exception& e) {
LK_LOG_ERROR("Room::disconnect: FFI disconnect failed: {}", e.what());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case should we be setting connection_state_ back to the previous state?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch -- fixing

alan-george-lk and others added 4 commits May 29, 2026 13:53
The kEos RoomEvent handler moves out and destroys the local participant
without first calling shutdown(). If the listener thread is mid-RPC-
invocation when kEos arrives, the participant's FfiHandle is dropped
while a handler is still in flight; the handler's later sendRequest
then hits an invalid Rust handle and the uncaught std::runtime_error
on the listener thread aborts the process. Mirror the ordering used
in disconnect(): call shutdown() on the moved-out participant before
letting it destruct.

Add INFO-level tracing at the key lifecycle points (~Room, disconnect,
kDisconnected, kEos, FfiHandle drops, INVALID_HANDLE error path) and
DEBUG tracing on the RPC invocation hot path. Bump RUST_LOG in the
integration-test CI step so the Rust side's "handle not found" error
message lands in the log.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

2 participants