@@ -108,7 +108,7 @@ export class ConnectInNewWindowCommand implements Command {
108108 cancellable : true
109109 } ,
110110 async ( _ , cancelToken ) => {
111- await this . initializeLocalSSH ( wsData ! . id ) ;
111+ const localSSHInitSuccess = await this . initializeLocalSSH ( wsData ! . id ) ;
112112
113113 if ( wsState . isWorkspaceStopped ) {
114114 // Start workspace automatically
@@ -128,18 +128,20 @@ export class ConnectInNewWindowCommand implements Command {
128128 const sshHostname = `${ wsData ! . id } .${ domain } ` ;
129129 const localSSHDestination = new SSHDestination ( sshHostname , wsData ! . id ) ;
130130 let localSSHTestSuccess : boolean = false ;
131- try {
132- await testLocalSSHConnection ( localSSHDestination . user ! , localSSHDestination . hostname ) ;
133- localSSHTestSuccess = true ;
134- } catch ( e ) {
135- this . telemetryService . sendTelemetryException (
136- new WrapError ( 'Local SSH: failed to connect to workspace' , e ) ,
137- {
138- gitpodHost : this . hostService . gitpodHost ,
139- openSSHVersion : await getOpenSSHVersion ( ) ,
140- workspaceId : wsData ! . id ,
141- }
142- ) ;
131+ if ( localSSHInitSuccess ) {
132+ try {
133+ await testLocalSSHConnection ( localSSHDestination . user ! , localSSHDestination . hostname ) ;
134+ localSSHTestSuccess = true ;
135+ } catch ( e ) {
136+ this . telemetryService . sendTelemetryException (
137+ new WrapError ( 'Local SSH: failed to connect to workspace' , e ) ,
138+ {
139+ gitpodHost : this . hostService . gitpodHost ,
140+ openSSHVersion : await getOpenSSHVersion ( ) ,
141+ workspaceId : wsData ! . id ,
142+ }
143+ ) ;
144+ }
143145 }
144146
145147 let sshDest : SSHDestination ;
@@ -183,6 +185,7 @@ export class ConnectInNewWindowCommand implements Command {
183185 this . remoteService . setupSSHProxy ( ) ,
184186 this . remoteService . startLocalSSHServiceServer ( )
185187 ] ) ;
188+ return true ;
186189 } catch ( e ) {
187190 this . telemetryService . sendTelemetryException ( new WrapError ( 'Local SSH: failed to initialize local SSH' , e ) , {
188191 gitpodHost : this . hostService . gitpodHost ,
@@ -191,6 +194,7 @@ export class ConnectInNewWindowCommand implements Command {
191194
192195 } ) ;
193196 this . logService . error ( `Local SSH: failed to initialize local SSH` , e ) ;
197+ return false ;
194198 }
195199 }
196200}
@@ -272,7 +276,7 @@ export class ConnectInCurrentWindowCommand implements Command {
272276 cancellable : true
273277 } ,
274278 async ( _ , cancelToken ) => {
275- await this . initializeLocalSSH ( wsData ! . id ) ;
279+ const localSSHInitSuccess = await this . initializeLocalSSH ( wsData ! . id ) ;
276280
277281 if ( wsState . isWorkspaceStopped ) {
278282 // Start workspace automatically
@@ -292,18 +296,21 @@ export class ConnectInCurrentWindowCommand implements Command {
292296 const sshHostname = `${ wsData ! . id } .${ domain } ` ;
293297 const localSSHDestination = new SSHDestination ( sshHostname , wsData ! . id ) ;
294298 let localSSHTestSuccess : boolean = false ;
295- try {
296- await testLocalSSHConnection ( localSSHDestination . user ! , localSSHDestination . hostname ) ;
297- localSSHTestSuccess = true ;
298- } catch ( e ) {
299- this . telemetryService . sendTelemetryException (
300- new WrapError ( 'Local SSH: failed to connect to workspace' , e ) ,
301- {
302- gitpodHost : this . hostService . gitpodHost ,
303- openSSHVersion : await getOpenSSHVersion ( ) ,
304- workspaceId : wsData ! . id ,
305- }
306- ) ;
299+ if ( localSSHInitSuccess ) {
300+ try {
301+ // TODO: test without check results of initializeLocalSSH will make test failed more often
302+ await testLocalSSHConnection ( localSSHDestination . user ! , localSSHDestination . hostname ) ;
303+ localSSHTestSuccess = true ;
304+ } catch ( e ) {
305+ this . telemetryService . sendTelemetryException (
306+ new WrapError ( 'Local SSH: failed to connect to workspace' , e ) ,
307+ {
308+ gitpodHost : this . hostService . gitpodHost ,
309+ openSSHVersion : await getOpenSSHVersion ( ) ,
310+ workspaceId : wsData ! . id ,
311+ }
312+ ) ;
313+ }
307314 }
308315
309316 let sshDest : SSHDestination ;
@@ -347,6 +354,7 @@ export class ConnectInCurrentWindowCommand implements Command {
347354 this . remoteService . setupSSHProxy ( ) ,
348355 this . remoteService . startLocalSSHServiceServer ( )
349356 ] ) ;
357+ return true ;
350358 } catch ( e ) {
351359 this . telemetryService . sendTelemetryException ( new WrapError ( 'Local SSH: failed to initialize local SSH' , e ) , {
352360 gitpodHost : this . hostService . gitpodHost ,
@@ -355,6 +363,7 @@ export class ConnectInCurrentWindowCommand implements Command {
355363
356364 } ) ;
357365 this . logService . error ( `Local SSH: failed to initialize local SSH` , e ) ;
366+ return false ;
358367 }
359368 }
360369}
0 commit comments