diff --git a/.changeset/fair-laws-yell.md b/.changeset/fair-laws-yell.md new file mode 100644 index 0000000000..5ef57c0037 --- /dev/null +++ b/.changeset/fair-laws-yell.md @@ -0,0 +1,5 @@ +--- +'livekit-client': patch +--- + +fix: prevent monitoring leak when stopOnUnpublish is false diff --git a/src/room/Room.ts b/src/room/Room.ts index ce9e7235c1..6319d1768d 100644 --- a/src/room/Room.ts +++ b/src/room/Room.ts @@ -1347,6 +1347,8 @@ class Room extends (EventEmitter as new () => TypedEmitter) if (shouldStopTracks) { pub.track?.detach(); pub.track?.stop(); + } else { + pub.track?.stopMonitor(); } }); diff --git a/src/room/participant/LocalParticipant.ts b/src/room/participant/LocalParticipant.ts index 5504ed6e7f..71f0deac94 100644 --- a/src/room/participant/LocalParticipant.ts +++ b/src/room/participant/LocalParticipant.ts @@ -1266,6 +1266,8 @@ export default class LocalParticipant extends Participant { } if (stopOnUnpublish) { track.stop(); + } else { + track.stopMonitor(); } let negotiationNeeded = false;