Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/always_emit_disconnected_on_engine_close.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
livekit: patch
livekit-ffi: patch
---

Bugfix: Always emit Disconnected on engine close - #1096 (@MaxHeimbrock)
7 changes: 6 additions & 1 deletion livekit/src/rtc_engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,13 @@ impl EngineInner {
session.close(reason).await;
let _ = close_tx.send(());
let _ = engine_task.await;
let _ = self.engine_tx.send(EngineEvent::Disconnected { reason });
}

// Always emit Disconnected, even when the engine_task was already taken by a
// prior failed `try_restart_connection`. Without this, a reconnect cycle that
// exhausts all attempts leaves the room stuck in Reconnecting forever because
// the room's task never sees the event that drives `handle_disconnected`.
let _ = self.engine_tx.send(EngineEvent::Disconnected { reason });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

any chance that there could be duplicated disconnected events ?

what will happen if close() is called multiple times ?

}

/// When waiting for reconnection, it ensures we're always using the latest session.
Expand Down
Loading