@@ -137,14 +137,24 @@ ngApp
137137 }
138138 this . tasks ( this . sockets [ socket ] , options ) ;
139139 }
140+ closeSocket ( dtpSocket ) {
141+ delete this . sockets [ dtpSocket . socket ] ;
142+ dtpSocket . ws . close ( ) ;
143+ }
140144 updateSocket ( websocketId , socketUrl , options ) {
141145 let parsed = this . parseWebSocketUrl ( socketUrl ) ;
142146 let scheme = parsed [ 1 ] ,
143147 socket = parsed [ 2 ] ,
144148 uuid = parsed [ 3 ] ;
145- let url = `${ scheme } ://${ socket } /${ uuid } `
146- let ws = new WebSocket ( url ) ;
147- this . sockets [ socket ] = { messageIndex : 0 , socketUrl : url , ws, socket } ;
149+ let url = `${ scheme } ://${ socket } /${ uuid } ` ;
150+ this . sockets [ socket ] . ws . close ( ) ;
151+ delete this . sockets [ socket ] . ws ;
152+ this . sockets [ socket ] = {
153+ messageIndex : 0 ,
154+ socketUrl : url ,
155+ ws : new WebSocket ( url ) ,
156+ socket
157+ } ;
148158 return this . tasks ( this . sockets [ socket ] , options ) ;
149159 }
150160 tasks ( socket , options ) {
@@ -900,7 +910,7 @@ ngApp
900910 } else if ( localSession . auto && isLocked ( instance ) ) {
901911 /** If the isLocked(getInstance()) is set then we still have to check for disconnects on the client side via httpGetTest().
902912 until there exists an event for the DevTools websocket disconnect. Currently there doesn't seem to be one
903- that we can use simultanous to DevTools itself as only one connection to the protocol is allowed at a time.
913+ that we can use simultaneous to DevTools itself as only one connection to the protocol is allowed at a time.
904914 */
905915 SingletonHttpGet . getInstance ( instance ) ;
906916 }
@@ -1181,6 +1191,7 @@ ngApp
11811191 }
11821192 }
11831193 function removeDevToolsSession ( devToolsSession , index ) {
1194+ $scope . devToolsProtocolClient . closeSocket ( devToolsSession . dtpSocket ) ;
11841195 if ( ! devToolsSession . isWindow ) {
11851196 $window . _gaq . push ( [ '_trackEvent' , 'Program Event' , 'removeDevToolsSession' , 'window' , undefined , true ] ) ;
11861197 chrome . tabs . remove ( devToolsSession . id , function ( ) {
@@ -1654,6 +1665,7 @@ ngApp
16541665 // Why am I not calling deleteSession() here?
16551666 $scope . devToolsSessions . splice ( $scope . devToolsSessions . findIndex ( function ( devToolsSession ) {
16561667 if ( devToolsSession . id === tabId ) {
1668+ $scope . devToolsProtocolClient . closeSocket ( devToolsSession . dtpSocket ) ;
16571669 unlock ( hostPortHashmap ( tabId ) ) ;
16581670 return true ;
16591671 }
0 commit comments