Skip to content

Commit 02c8094

Browse files
authored
Fix error handling in example (#1835)
1 parent 1b93409 commit 02c8094

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

.changeset/ninety-plants-reply.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
"livekit-client": patch
2+
'livekit-client': patch
33
---
44

55
Use controller.error to signal unexpected errors mid data stream

examples/demo/demo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ const appActions = {
284284
);
285285
}
286286
} catch (err) {
287+
console.error('text stream error', err);
287288
message += 'ERROR';
288289
handleChatMessage(
289290
{
@@ -293,7 +294,6 @@ const appActions = {
293294
},
294295
room.getParticipantByIdentity(participant?.identity),
295296
);
296-
throw err;
297297
}
298298

299299
if (!info.size) {

src/room/data-stream/incoming/StreamReader.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ export class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {
7171

7272
[Symbol.asyncIterator]() {
7373
const reader = this.reader.getReader();
74+
// Suppress unhandled rejection on reader.closed — errors are
75+
// already propagated through reader.read() to the consumer.
76+
reader.closed.catch(() => {});
7477

7578
const cleanup = () => {
7679
reader.releaseLock();
@@ -195,6 +198,9 @@ export class TextStreamReader extends BaseStreamReader<TextStreamInfo> {
195198
*/
196199
[Symbol.asyncIterator]() {
197200
const reader = this.reader.getReader();
201+
// Suppress unhandled rejection on reader.closed — errors are
202+
// already propagated through reader.read() to the consumer.
203+
reader.closed.catch(() => {});
198204
const decoder = new TextDecoder('utf-8', { fatal: true });
199205
const signal = this.signal;
200206

0 commit comments

Comments
 (0)