@@ -108,7 +108,7 @@ export class ConnectInNewWindowCommand implements Command {
108
108
cancellable : true
109
109
} ,
110
110
async ( _ , cancelToken ) => {
111
- await this . initializeLocalSSH ( wsData ! . id ) ;
111
+ const localSSHInitSuccess = await this . initializeLocalSSH ( wsData ! . id ) ;
112
112
113
113
if ( wsState . isWorkspaceStopped ) {
114
114
// Start workspace automatically
@@ -128,18 +128,20 @@ export class ConnectInNewWindowCommand implements Command {
128
128
const sshHostname = `${ wsData ! . id } .${ domain } ` ;
129
129
const localSSHDestination = new SSHDestination ( sshHostname , wsData ! . id ) ;
130
130
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
+ }
143
145
}
144
146
145
147
let sshDest : SSHDestination ;
@@ -183,6 +185,7 @@ export class ConnectInNewWindowCommand implements Command {
183
185
this . remoteService . setupSSHProxy ( ) ,
184
186
this . remoteService . startLocalSSHServiceServer ( )
185
187
] ) ;
188
+ return true ;
186
189
} catch ( e ) {
187
190
this . telemetryService . sendTelemetryException ( new WrapError ( 'Local SSH: failed to initialize local SSH' , e ) , {
188
191
gitpodHost : this . hostService . gitpodHost ,
@@ -191,6 +194,7 @@ export class ConnectInNewWindowCommand implements Command {
191
194
192
195
} ) ;
193
196
this . logService . error ( `Local SSH: failed to initialize local SSH` , e ) ;
197
+ return false ;
194
198
}
195
199
}
196
200
}
@@ -272,7 +276,7 @@ export class ConnectInCurrentWindowCommand implements Command {
272
276
cancellable : true
273
277
} ,
274
278
async ( _ , cancelToken ) => {
275
- await this . initializeLocalSSH ( wsData ! . id ) ;
279
+ const localSSHInitSuccess = await this . initializeLocalSSH ( wsData ! . id ) ;
276
280
277
281
if ( wsState . isWorkspaceStopped ) {
278
282
// Start workspace automatically
@@ -292,18 +296,21 @@ export class ConnectInCurrentWindowCommand implements Command {
292
296
const sshHostname = `${ wsData ! . id } .${ domain } ` ;
293
297
const localSSHDestination = new SSHDestination ( sshHostname , wsData ! . id ) ;
294
298
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
+ }
307
314
}
308
315
309
316
let sshDest : SSHDestination ;
@@ -347,6 +354,7 @@ export class ConnectInCurrentWindowCommand implements Command {
347
354
this . remoteService . setupSSHProxy ( ) ,
348
355
this . remoteService . startLocalSSHServiceServer ( )
349
356
] ) ;
357
+ return true ;
350
358
} catch ( e ) {
351
359
this . telemetryService . sendTelemetryException ( new WrapError ( 'Local SSH: failed to initialize local SSH' , e ) , {
352
360
gitpodHost : this . hostService . gitpodHost ,
@@ -355,6 +363,7 @@ export class ConnectInCurrentWindowCommand implements Command {
355
363
356
364
} ) ;
357
365
this . logService . error ( `Local SSH: failed to initialize local SSH` , e ) ;
366
+ return false ;
358
367
}
359
368
}
360
369
}
0 commit comments