File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -383,10 +383,14 @@ export default class RTCPeerConnection extends EventTarget implements globalThis
383
383
getStats ( ) : Promise < globalThis . RTCStatsReport > {
384
384
return new Promise ( ( resolve ) => {
385
385
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
+ }
390
394
391
395
const localIdRs = getRandomString ( 8 ) ;
392
396
const localId = 'RTCIceCandidate_' + localIdRs ;
You can’t perform that action at this time.
0 commit comments