@@ -9,7 +9,7 @@ import { LocalAppClient } from '@gitpod/local-app-api-grpcweb/lib/localapp_pb_se
9
9
import { NodeHttpTransport } from '@improbable-eng/grpc-web-node-http-transport' ;
10
10
import { grpc } from '@improbable-eng/grpc-web' ;
11
11
import { Workspace , WorkspaceInstanceStatus_Phase } from '@gitpod/public-api/lib/gitpod/experimental/v1/workspaces_pb' ;
12
- import { UserSSHPublicKeyValue , WorkspaceInfo } from '@gitpod/gitpod-protocol' ;
12
+ import { UserSSHPublicKeyValue , WorkspaceInfo , WorkspaceInstancePhase } from '@gitpod/gitpod-protocol' ;
13
13
import * as cp from 'child_process' ;
14
14
import * as fs from 'fs' ;
15
15
import * as http from 'http' ;
@@ -110,8 +110,8 @@ class LocalAppError extends Error {
110
110
}
111
111
112
112
class NoRunningInstanceError extends Error {
113
- constructor ( readonly workspaceId : string ) {
114
- super ( `Failed to connect to ${ workspaceId } Gitpod workspace, workspace not running` ) ;
113
+ constructor ( readonly workspaceId : string , phase ?: WorkspaceInstancePhase ) {
114
+ super ( `Failed to connect to ${ workspaceId } Gitpod workspace, workspace not running: ${ phase } ` ) ;
115
115
}
116
116
}
117
117
@@ -1024,9 +1024,12 @@ export default class RemoteConnector extends Disposable {
1024
1024
throw new Error ( 'No Gitpod session available' ) ;
1025
1025
}
1026
1026
1027
- const workspaceInfo = await withServerApi ( session . accessToken , connectionInfo . gitpodHost , service => service . server . getWorkspace ( connectionInfo . workspaceId ) , this . logger ) ;
1027
+ const workspaceInfo = await retry ( async ( ) => {
1028
+ return await withServerApi ( session ! . accessToken , connectionInfo . gitpodHost , service => service . server . getWorkspace ( connectionInfo . workspaceId ) , this . logger ) ;
1029
+ } , 500 , 3 ) ;
1030
+
1028
1031
if ( workspaceInfo . latestInstance ?. status ?. phase !== 'running' ) {
1029
- throw new NoRunningInstanceError ( connectionInfo . workspaceId ) ;
1032
+ throw new NoRunningInstanceError ( connectionInfo . workspaceId , workspaceInfo . latestInstance ?. status ?. phase ) ;
1030
1033
}
1031
1034
1032
1035
if ( workspaceInfo . latestInstance . id !== connectionInfo . instanceId ) {
@@ -1069,8 +1072,12 @@ export default class RemoteConnector extends Disposable {
1069
1072
1070
1073
vscode . commands . executeCommand ( 'setContext' , 'gitpod.inWorkspace' , true ) ;
1071
1074
} catch ( e ) {
1072
- e . message = `Failed to resolve whole gitpod remote connection process: ${ e . message } ` ;
1073
- this . logger . error ( e ) ;
1075
+ if ( e instanceof NoRunningInstanceError ) {
1076
+ this . logger . error ( 'No Running instance:' , e ) ;
1077
+ return ;
1078
+ }
1079
+ e . message = `Failed to resolve whole gitpod remote connection process: ${ e . message } ` ;
1080
+ this . logger . error ( e ) ;
1074
1081
this . telemetry . sendTelemetryException ( e , { workspaceId : connectionInfo . workspaceId , instanceId : connectionInfo . instanceId , userId : session ?. account . id || '' } ) ;
1075
1082
}
1076
1083
}
0 commit comments