Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not attempt to add subscribed track when disconnected #299

Merged
merged 2 commits into from
Jul 2, 2022
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
5 changes: 5 additions & 0 deletions .changeset/dry-geckos-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Do not attempt to add subscribed track when disconnected
7 changes: 4 additions & 3 deletions src/room/Room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,15 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
// at that time, ICE connectivity has not been established so the track is not
// technically subscribed.
// We'll defer these events until when the room is connected or eventually disconnected.
if (this.state === ConnectionState.Connecting || this.state === ConnectionState.Reconnecting) {
setTimeout(() => {
if (this.connectFuture) {
this.connectFuture.promise.then(() => {
this.onTrackAdded(mediaTrack, stream, receiver);
}, 50);
});
return;
}
if (this.state === ConnectionState.Disconnected) {
log.warn('skipping incoming track after Room disconnected');
return;
}
const parts = unpackStreamId(stream.id);
const participantId = parts[0];
Expand Down