File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
packages/devtools-websocket-connector/src Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,12 @@ export class DevtoolsWebSocketConnector implements Connector {
5454 if ( this . destroyed ) {
5555 throw new Error ( "Connector is destroyed" ) ;
5656 }
57- if ( this . ws && this . wsUrl === params . url ) {
57+ if (
58+ this . ws &&
59+ this . wsUrl === params . url &&
60+ ( this . ws . readyState === WebSocket . OPEN ||
61+ this . ws . readyState === WebSocket . CONNECTING )
62+ ) {
5863 const mapReadyStateToText = ( readyState : number ) => {
5964 switch ( readyState ) {
6065 case WebSocket . OPEN :
@@ -112,6 +117,10 @@ export class DevtoolsWebSocketConnector implements Connector {
112117 console . log ( "[DevtoolsWebSocketConnector] WebSocket closed" ) ;
113118 this . ws = null ;
114119 this . wsUrl = null ;
120+ if ( this . messagesToSendSubscription ) {
121+ this . messagesToSendSubscription . unsubscribe ( ) ;
122+ this . messagesToSendSubscription = null ;
123+ }
115124 } ;
116125
117126 this . ws . onerror = ( event ) => {
@@ -134,7 +143,7 @@ export class DevtoolsWebSocketConnector implements Connector {
134143 if ( websocketMessageType === WEBSOCKET_MESSAGE_TYPES . MESSAGE ) {
135144 try {
136145 const parsedMessage = JSON . parse (
137- websocketMessagePayload as string ,
146+ websocketMessagePayload ,
138147 ) as { type ?: unknown ; payload ?: unknown } ;
139148 const type = parsedMessage . type ;
140149 const payload = parsedMessage . payload ;
You can’t perform that action at this time.
0 commit comments