Skip to content
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/giant-ligers-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Avoid uncaught errors related to send/disconnect races
8 changes: 6 additions & 2 deletions src/room/RTCEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit

// create offer
if (!this.subscriberPrimary || joinResponse.fastPublish) {
this.negotiate();
this.negotiate().catch((err) => {
log.error(err, this.logContext);
});
}

this.registerOnLineListener();
Expand Down Expand Up @@ -1338,7 +1340,9 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
}
if (needNegotiation) {
// start negotiation
this.negotiate();
this.negotiate().catch((err) => {
log.error(err, this.logContext);
});
}

const targetChannel = this.dataChannelForKind(kind, subscriber);
Expand Down
7 changes: 7 additions & 0 deletions src/room/data-stream/incoming/IncomingDataStreamManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export default class IncomingDataStreamManager {

let streamController: ReadableStreamDefaultController<DataStream_Chunk>;
const outOfBandFailureRejectingFuture = new Future<never>();
outOfBandFailureRejectingFuture.promise.catch((err) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1egoman does this look reasonable to you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, it doesn't seem like it interferes with the existing logic, just logs a copy of any errors 👍

this.log.error(err);
});

const info: ByteStreamInfo = {
id: streamHeader.streamId,
Expand Down Expand Up @@ -178,6 +181,10 @@ export default class IncomingDataStreamManager {

let streamController: ReadableStreamDefaultController<DataStream_Chunk>;
const outOfBandFailureRejectingFuture = new Future<never>();
outOfBandFailureRejectingFuture.promise.catch((err) => {
this.log.error(err);
});

const info: TextStreamInfo = {
id: streamHeader.streamId,
mimeType: streamHeader.mimeType,
Expand Down
Loading