@@ -63,7 +63,17 @@ export interface OKMessage {
63
63
type : 'ok' ;
64
64
}
65
65
66
- export type HandshakeMessage = AuthRequest | SignRequest | ConnectionTypeRequest | ErrorMessage | OKMessage ;
66
+ /**
67
+ * Expected response from `CodeServer` connection.
68
+ * @coder Moved from inline type for use outside this module.
69
+ */
70
+ export interface DebugMessage {
71
+ type : 'debug' ;
72
+ debugPort ?: NonNullable < IRemoteExtensionHostStartParams [ 'port' ] > ;
73
+ }
74
+
75
+
76
+ export type HandshakeMessage = AuthRequest | SignRequest | ConnectionTypeRequest | ErrorMessage | OKMessage | DebugMessage ;
67
77
68
78
69
79
interface ISimpleConnectionOptions {
@@ -225,20 +235,22 @@ function raceWithTimeoutCancellation<T>(promise: Promise<T>, timeoutCancellation
225
235
async function connectToRemoteExtensionHostAgent ( options : ISimpleConnectionOptions , connectionType : ConnectionType , args : any | undefined , timeoutCancellationToken : CancellationToken ) : Promise < { protocol : PersistentProtocol ; ownsProtocol : boolean ; } > {
226
236
const logPrefix = connectLogPrefix ( options , connectionType ) ;
227
237
228
- options . logService . trace ( `${ logPrefix } 1/6. invoking socketFactory.connect().` ) ;
238
+ options . logService . info ( `${ logPrefix } 1/6. invoking socketFactory.connect().` ) ;
229
239
230
240
let socket : ISocket ;
231
241
try {
232
- // NOTE@coder : Add connection type to the socket. This is so they can be
233
- // distinguished by the backend.
242
+ /**
243
+ * @coder Add connection type to the socket.
244
+ * This is so they can be distinguished by the backend.
245
+ */
234
246
socket = await createSocket ( options . logService , options . socketFactory , options . host , options . port , `type=${ connectionTypeToString ( connectionType ) } &reconnectionToken=${ options . reconnectionToken } &reconnection=${ options . reconnectionProtocol ? 'true' : 'false' } ` , timeoutCancellationToken ) ;
235
247
} catch ( error ) {
236
248
options . logService . error ( `${ logPrefix } socketFactory.connect() failed or timed out. Error:` ) ;
237
249
options . logService . error ( error ) ;
238
250
throw error ;
239
251
}
240
252
241
- options . logService . trace ( `${ logPrefix } 2/6. socketFactory.connect() was successful.` ) ;
253
+ options . logService . info ( `${ logPrefix } 2/6. socketFactory.connect() was successful.` ) ;
242
254
243
255
let protocol : PersistentProtocol ;
244
256
let ownsProtocol : boolean ;
@@ -251,7 +263,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
251
263
ownsProtocol = true ;
252
264
}
253
265
254
- options . logService . trace ( `${ logPrefix } 3/6. sending AuthRequest control message.` ) ;
266
+ options . logService . info ( `${ logPrefix } 3/6. sending AuthRequest control message.` ) ;
255
267
const authRequest : AuthRequest = {
256
268
type : 'auth' ,
257
269
auth : options . connectionToken || '00000000000000000000'
@@ -267,7 +279,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
267
279
throw error ;
268
280
}
269
281
270
- options . logService . trace ( `${ logPrefix } 4/6. received SignRequest control message.` ) ;
282
+ options . logService . info ( `${ logPrefix } 4/6. received SignRequest control message.` ) ;
271
283
272
284
const signed = await raceWithTimeoutCancellation ( options . signService . sign ( msg . data ) , timeoutCancellationToken ) ;
273
285
const connTypeRequest : ConnectionTypeRequest = {
@@ -280,7 +292,7 @@ async function connectToRemoteExtensionHostAgent(options: ISimpleConnectionOptio
280
292
connTypeRequest . args = args ;
281
293
}
282
294
283
- options . logService . trace ( `${ logPrefix } 5/6. sending ConnectionTypeRequest control message.` ) ;
295
+ options . logService . info ( `${ logPrefix } 5/6. sending ConnectionTypeRequest control message.` ) ;
284
296
protocol . sendControl ( VSBuffer . fromString ( JSON . stringify ( connTypeRequest ) ) ) ;
285
297
286
298
return { protocol, ownsProtocol } ;
@@ -324,7 +336,7 @@ async function connectToRemoteExtensionHostAgentAndReadOneMessage<T>(options: IS
324
336
if ( options . reconnectionProtocol ) {
325
337
options . reconnectionProtocol . endAcceptReconnection ( ) ;
326
338
}
327
- options . logService . trace ( `${ logPrefix } 6/6. handshake finished, connection is up and running after ${ logElapsed ( startTime ) } !` ) ;
339
+ options . logService . info ( `${ logPrefix } 6/6. handshake finished, connection is up and running after ${ logElapsed ( startTime ) } !` ) ;
328
340
result . resolve ( { protocol, firstMessage : msg } ) ;
329
341
}
330
342
} ) ) ;
@@ -350,7 +362,9 @@ interface IExtensionHostConnectionResult {
350
362
}
351
363
352
364
async function doConnectRemoteAgentExtensionHost ( options : ISimpleConnectionOptions , startArguments : IRemoteExtensionHostStartParams , timeoutCancellationToken : CancellationToken ) : Promise < IExtensionHostConnectionResult > {
353
- const { protocol, firstMessage } = await connectToRemoteExtensionHostAgentAndReadOneMessage < { debugPort ?: number ; } > ( options , ConnectionType . ExtensionHost , startArguments , timeoutCancellationToken ) ;
365
+ console . log ( '>>> READING ONE MESSAGE' , options , startArguments ) ;
366
+ const { protocol, firstMessage } = await connectToRemoteExtensionHostAgentAndReadOneMessage < DebugMessage > ( options , ConnectionType . ExtensionHost , startArguments , timeoutCancellationToken ) ;
367
+ console . log ( '>>> READ ONE MESSAGE' , JSON . stringify ( firstMessage ) ) ;
354
368
const debugPort = firstMessage && firstMessage . debugPort ;
355
369
return { protocol, debugPort } ;
356
370
}
@@ -363,7 +377,7 @@ async function doConnectRemoteAgentTunnel(options: ISimpleConnectionOptions, sta
363
377
const startTime = Date . now ( ) ;
364
378
const logPrefix = connectLogPrefix ( options , ConnectionType . Tunnel ) ;
365
379
const { protocol } = await connectToRemoteExtensionHostAgent ( options , ConnectionType . Tunnel , startParams , timeoutCancellationToken ) ;
366
- options . logService . trace ( `${ logPrefix } 6/6. handshake finished, connection is up and running after ${ logElapsed ( startTime ) } !` ) ;
380
+ options . logService . info ( `${ logPrefix } 6/6. handshake finished, connection is up and running after ${ logElapsed ( startTime ) } !` ) ;
367
381
return protocol ;
368
382
}
369
383
@@ -553,7 +567,7 @@ abstract class PersistentConnection extends Disposable {
553
567
} ) ) ;
554
568
this . _register ( protocol . onSocketTimeout ( ( ) => {
555
569
const logPrefix = commonLogPrefix ( this . _connectionType , this . reconnectionToken , true ) ;
556
- this . _options . logService . trace ( `${ logPrefix } received socket timeout event.` ) ;
570
+ this . _options . logService . info ( `${ logPrefix } received socket timeout event.` ) ;
557
571
this . _beginReconnecting ( ) ;
558
572
} ) ) ;
559
573
@@ -632,19 +646,19 @@ abstract class PersistentConnection extends Disposable {
632
646
}
633
647
if ( RemoteAuthorityResolverError . isTemporarilyNotAvailable ( err ) ) {
634
648
this . _options . logService . info ( `${ logPrefix } A temporarily not available error occurred while trying to reconnect, will try again...` ) ;
635
- this . _options . logService . trace ( err ) ;
649
+ this . _options . logService . info ( err ) ;
636
650
// try again!
637
651
continue ;
638
652
}
639
653
if ( ( err . code === 'ETIMEDOUT' || err . code === 'ENETUNREACH' || err . code === 'ECONNREFUSED' || err . code === 'ECONNRESET' ) && err . syscall === 'connect' ) {
640
654
this . _options . logService . info ( `${ logPrefix } A network error occurred while trying to reconnect, will try again...` ) ;
641
- this . _options . logService . trace ( err ) ;
655
+ this . _options . logService . info ( err ) ;
642
656
// try again!
643
657
continue ;
644
658
}
645
659
if ( isPromiseCanceledError ( err ) ) {
646
660
this . _options . logService . info ( `${ logPrefix } A promise cancelation error occurred while trying to reconnect, will try again...` ) ;
647
- this . _options . logService . trace ( err ) ;
661
+ this . _options . logService . info ( err ) ;
648
662
// try again!
649
663
continue ;
650
664
}
0 commit comments