Skip to content

Commit 341c432

Browse files
authored
chore: log ws error code if available (#1593)
1 parent b5590ef commit 341c432

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

.changeset/afraid-phones-tickle.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+
chore: log ws error code if available

src/api/SignalClient.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,11 @@ export class SignalClient {
324324
const msg = await resp.text();
325325
reject(new ConnectionError(msg, ConnectionErrorReason.NotAllowed, resp.status));
326326
} else {
327-
reject(
328-
new ConnectionError(
329-
`Encountered unknown websocket error during connection: ${ev.toString()}`,
330-
ConnectionErrorReason.InternalError,
331-
resp.status,
332-
),
333-
);
327+
// we don't want to reject here as the `close` event will be triggered and might have a more specific error
328+
this.log.error(`Encountered unknown websocket error during connection`, {
329+
...this.logContext,
330+
error: ev,
331+
});
334332
}
335333
} catch (e) {
336334
reject(
@@ -431,7 +429,7 @@ export class SignalClient {
431429
if (this.isEstablishingConnection) {
432430
reject(
433431
new ConnectionError(
434-
'Websocket got closed during a (re)connection attempt',
432+
`Websocket got closed during a (re)connection attempt. Reason: ${ev.reason}, Code: ${ev.code}, Was clean: ${ev.wasClean}`,
435433
ConnectionErrorReason.InternalError,
436434
),
437435
);

0 commit comments

Comments
 (0)