@@ -187,6 +187,10 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
187
187
}
188
188
189
189
private setConnection ( connection : INSDebugConnection ) : INSDebugConnection {
190
+ if ( this . _webKitConnection ) {
191
+ this . _webKitConnection . close ( ) ;
192
+ }
193
+ this . _webKitConnection = connection ;
190
194
connection . on ( 'Debugger.paused' , params => this . onDebuggerPaused ( params ) ) ;
191
195
connection . on ( 'Debugger.resumed' , ( ) => this . onDebuggerResumed ( ) ) ;
192
196
connection . on ( 'Debugger.scriptParsed' , params => this . onScriptParsed ( params ) ) ;
@@ -201,7 +205,6 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
201
205
this . terminateSession ( ) ;
202
206
} ) ;
203
207
connection . on ( 'connect' , ( ) => this . onConnected ( ) )
204
- this . _webKitConnection = connection ;
205
208
return connection ;
206
209
}
207
210
@@ -227,18 +230,6 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
227
230
private clearEverything ( ) : void {
228
231
this . clearClientContext ( ) ;
229
232
this . clearTargetContext ( ) ;
230
-
231
- if ( this . _tnsProcess ) {
232
- this . _tnsProcess . kill ( 'SIGQUIT' ) ;
233
- this . _tnsProcess = null ;
234
- }
235
-
236
- if ( this . _webKitConnection ) {
237
- Services . logger ( ) . log ( "Closing debug connection" ) ;
238
-
239
- this . _webKitConnection . close ( ) ;
240
- this . _webKitConnection = null ;
241
- }
242
233
}
243
234
244
235
/**
@@ -346,6 +337,15 @@ export class WebKitDebugAdapter implements DebugProtocol.IDebugAdapter {
346
337
347
338
public disconnect ( ) : Promise < void > {
348
339
this . clearEverything ( ) ;
340
+ if ( this . _tnsProcess ) {
341
+ this . _tnsProcess . kill ( 'SIGQUIT' ) ;
342
+ this . _tnsProcess = null ;
343
+ }
344
+ if ( this . _webKitConnection ) {
345
+ Services . logger ( ) . log ( "Closing debug connection" ) ;
346
+ this . _webKitConnection . close ( ) ;
347
+ this . _webKitConnection = null ;
348
+ }
349
349
350
350
return Promise . resolve < void > ( ) ;
351
351
}
0 commit comments