Skip to content

Commit 6214558

Browse files
authored
Close streamcontrollers when datatrack gets unpublished (#1879)
1 parent 5864b2a commit 6214558

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

.changeset/quiet-suits-matter.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+
Close streamcontrollers when datatrack gets unpublished

src/room/data-track/incoming/IncomingDataTrackManager.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,9 @@ export default class IncomingDataTrackManager extends (EventEmitter as new () =>
436436
this.descriptors.delete(sid);
437437

438438
if (descriptor.subscription.type === 'active') {
439+
descriptor.subscription.streamControllers.forEach((controller) => {
440+
controller.close();
441+
});
439442
this.subscriptionHandles.delete(descriptor.subscription.subcriptionHandle);
440443
}
441444

@@ -583,6 +586,10 @@ export default class IncomingDataTrackManager extends (EventEmitter as new () =>
583586
if (descriptor.subscription.type === 'pending') {
584587
descriptor.subscription.completionFuture.reject?.(DataTrackSubscribeError.disconnected());
585588
}
589+
590+
if (descriptor.subscription.type === 'active') {
591+
descriptor.subscription.streamControllers.forEach((controller) => controller.close());
592+
}
586593
}
587594
this.descriptors.clear();
588595
}

0 commit comments

Comments
 (0)