Browse Source

dataChannel can be null before initialization

afrokick 6 years ago
parent
commit
31bd3d67ee
1 changed files with 3 additions and 2 deletions
  1. 3 2
      lib/negotiator.ts

+ 3 - 2
lib/negotiator.ts

@@ -193,8 +193,9 @@ export class Negotiator {
       const dataConnection = <DataConnection>this.connection;
       const dataConnection = <DataConnection>this.connection;
       const dataChannel = dataConnection.dataChannel;
       const dataChannel = dataConnection.dataChannel;
 
 
-      dataChannelNotClosed =
-        dataChannel.readyState && dataChannel.readyState !== "closed";
+      if (dataChannel) {
+        dataChannelNotClosed = !!dataChannel.readyState && dataChannel.readyState !== "closed";
+      }
     }
     }
 
 
     if (peerConnectionNotClosed || dataChannelNotClosed) {
     if (peerConnectionNotClosed || dataChannelNotClosed) {