Skip to content

Commit be38609

Browse files
committedNov 13, 2024
solves #301
1 parent 05b66ad commit be38609

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎src/polyfill/RTCPeerConnection.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,14 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
383383
getStats(): Promise<globalThis.RTCStatsReport> {
384384
return new Promise((resolve) => {
385385
const report = new Map();
386-
const cp = this.#peerConnection.getSelectedCandidatePair();
387-
const bytesSent = this.#peerConnection.bytesSent();
388-
const bytesReceived = this.#peerConnection.bytesReceived();
389-
const rtt = this.#peerConnection.rtt();
386+
const cp = this.#peerConnection?.getSelectedCandidatePair();
387+
const bytesSent = this.#peerConnection?.bytesSent();
388+
const bytesReceived = this.#peerConnection?.bytesReceived();
389+
const rtt = this.#peerConnection?.rtt();
390+
391+
if(!cp) {
392+
return resolve(report);
393+
}
390394

391395
const localIdRs = getRandomString(8);
392396
const localId = 'RTCIceCandidate_' + localIdRs;

0 commit comments

Comments
 (0)
Please sign in to comment.