diff --git a/packages/livekit-rtc/src/participant.ts b/packages/livekit-rtc/src/participant.ts index 70cd8256..17d21957 100644 --- a/packages/livekit-rtc/src/participant.ts +++ b/packages/livekit-rtc/src/participant.ts @@ -156,6 +156,10 @@ export class LocalParticipant extends Participant { return ev.message.case == 'publishTrack' && ev.message.value.asyncId == res.asyncId; }); + if (cb.error) { + throw new Error(cb.error); + } + const track_publication = new LocalTrackPublication(cb.publication); track_publication.track = track; this.trackPublications.set(track_publication.sid, track_publication); @@ -173,10 +177,14 @@ export class LocalParticipant extends Participant { message: { case: 'unpublishTrack', value: req }, }); - await FfiClient.instance.waitFor((ev) => { + const cb = await FfiClient.instance.waitFor((ev) => { return ev.message.case == 'unpublishTrack' && ev.message.value.asyncId == res.asyncId; }); + if (cb.error) { + throw new Error(cb.error); + } + const pub = this.trackPublications.get(trackSid); pub.track = undefined; this.trackPublications.delete(trackSid); diff --git a/packages/livekit-rtc/src/room.ts b/packages/livekit-rtc/src/room.ts index 143774f0..80591dfd 100644 --- a/packages/livekit-rtc/src/room.ts +++ b/packages/livekit-rtc/src/room.ts @@ -157,7 +157,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter }, }); - FfiClient.instance.removeAllListeners(); + FfiClient.instance.removeListener(FfiClientEvent.FfiEvent, this.onFfiEvent); this.removeAllListeners(); }