diff --git a/modules/xmpp/Lobby.js b/modules/xmpp/Lobby.js index 2256bafe98..50c3348f92 100644 --- a/modules/xmpp/Lobby.js +++ b/modules/xmpp/Lobby.js @@ -309,6 +309,11 @@ export default class Lobby { this.lobbyRoom.addEventListener( XMPPEvents.MUC_DESTROYED, (reason, jid) => { + this.lobbyRoom?.clean(); + + this.lobbyRoom = undefined; + logger.info('Lobby room left(destroyed)!'); + // we are receiving the jid of the main room // means we are invited to join, maybe lobby was disabled if (jid) { @@ -317,8 +322,6 @@ export default class Lobby { return; } - this.lobbyRoom.clean(); - this.mainRoom.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason); }); @@ -327,7 +330,9 @@ export default class Lobby { this.mainRoom.addEventListener( XMPPEvents.MUC_JOINED, () => { - this.leave(); + this.leave().catch(() => { + // this may happen if the room has been destroyed. + }); }); }