Skip to content

Commit 541309b

Browse files
authored
Fix potential undefined access while disconnecting (#1734)
1 parent 9c082be commit 541309b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

.changeset/popular-wolves-wait.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
Fix potential undefined access while disconnecting

src/room/Room.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,12 +967,13 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
967967
);
968968
this.connectFuture = undefined;
969969
}
970-
// send leave
971-
if (!this.engine?.client.isDisconnected) {
972-
await this.engine.client.sendLeave();
973-
}
970+
974971
// close engine (also closes client)
975972
if (this.engine) {
973+
// send leave
974+
if (!this.engine.client.isDisconnected) {
975+
await this.engine.client.sendLeave();
976+
}
976977
await this.engine.close();
977978
}
978979
this.handleDisconnect(stopTracks, DisconnectReason.CLIENT_INITIATED);

0 commit comments

Comments
 (0)