From 52e3a8ec983fbf7af92738a8a9c92130ae88f78a Mon Sep 17 00:00:00 2001 From: kwasniow Date: Mon, 29 Apr 2024 16:21:34 +0200 Subject: [PATCH] fix: add onicecandidateerror logging for easier debugging --- src/peer-connection.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/peer-connection.ts b/src/peer-connection.ts index 7018b49..b273a39 100644 --- a/src/peer-connection.ts +++ b/src/peer-connection.ts @@ -102,6 +102,16 @@ class PeerConnection extends EventEmitter { this.pc.onicecandidate = (ev: RTCPeerConnectionIceEvent) => { this.emit(PeerConnection.Events.IceCandidate, ev); }; + + this.pc.onicecandidateerror = (ev: Event) => { + try { + const { url, errorCode, errorText } = ev as RTCPeerConnectionIceErrorEvent; + + logger.warn(`ICE Candidate(${url}) error: ${errorCode}, with message: ${errorText}`); + } catch (error) { + logger.error(`Failed to log ICE Candidate error: ${error}`); + } + }; } /**