From e30046f537fd878720ce131fa8f86914872b278f Mon Sep 17 00:00:00 2001 From: David Zhao Date: Sun, 3 Jul 2022 23:38:59 -0700 Subject: [PATCH] Delay room manager close to ensure correct DisconnectReason is sent (#806) --- pkg/service/roommanager.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/service/roommanager.go b/pkg/service/roommanager.go index 3c64d639c..96db96b84 100644 --- a/pkg/service/roommanager.go +++ b/pkg/service/roommanager.go @@ -385,6 +385,9 @@ func (r *RoomManager) getOrCreateRoom(ctx context.Context, roomName livekit.Room // manages an RTC session for a participant, runs on the RTC node func (r *RoomManager) rtcSessionWorker(room *rtc.Room, participant types.LocalParticipant, requestSource routing.MessageSource) { defer func() { + // give time for the participant to be closed with a proper reason. + // if participant is closed from here, we would be obscuring the real reason the participant is closed. + time.Sleep(2 * time.Second) logger.Debugw("RTC session finishing", "participant", participant.Identity(), "pID", participant.ID(),