@@ -7,7 +7,7 @@ import { SshClient } from '@microsoft/dev-tunnels-ssh-tcp';
7
7
import { NodeStream , SshClientCredentials , SshClientSession , SshDisconnectReason , SshServerSession , SshSessionConfiguration , Stream , WebSocketStream } from '@microsoft/dev-tunnels-ssh' ;
8
8
import { importKey , importKeyBytes } from '@microsoft/dev-tunnels-ssh-keys' ;
9
9
import { ExtensionServiceDefinition , GetWorkspaceAuthInfoResponse } from '../proto/typescript/ipc/v1/ipc' ;
10
- import { Client , createChannel , createClient } from 'nice-grpc' ;
10
+ import { Client , ClientError , Status , createChannel , createClient } from 'nice-grpc' ;
11
11
import { retry } from '../common/async' ;
12
12
import { WebSocket } from 'ws' ;
13
13
import * as stream from 'stream' ;
@@ -41,7 +41,7 @@ function getClientOptions(): ClientOptions {
41
41
} ;
42
42
}
43
43
44
- type FailedToProxyCode = 'SSH.AuthenticationFailed' | 'TUNNEL.AuthenticateSSHKeyFailed' | 'NoRunningInstance' | 'FailedToGetAuthInfo' ;
44
+ type FailedToProxyCode = 'SSH.AuthenticationFailed' | 'TUNNEL.AuthenticateSSHKeyFailed' | 'NoRunningInstance' | 'FailedToGetAuthInfo' | 'GitpodHostMismatch' | 'NoAccessTokenFound' ;
45
45
46
46
// IgnoredFailedCodes contains the failreCode that don't need to send error report
47
47
const IgnoredFailedCodes : FailedToProxyCode [ ] = [ 'NoRunningInstance' ] ;
@@ -139,11 +139,11 @@ class WebSocketSSHProxy {
139
139
pipePromise = session . pipe ( pipeSession ) ;
140
140
return { } ;
141
141
} ) . catch ( async err => {
142
- let sendErrorReport = true
142
+ let sendErrorReport = true ;
143
143
if ( err instanceof FailedToProxyError ) {
144
144
this . flow . failureCode = err . failureCode ;
145
145
if ( IgnoredFailedCodes . includes ( err . failureCode ) ) {
146
- sendErrorReport = false
146
+ sendErrorReport = false ;
147
147
}
148
148
}
149
149
await Promise . allSettled ( [
@@ -236,6 +236,13 @@ class WebSocketSSHProxy {
236
236
async retryGetWorkspaceInfo ( username : string ) {
237
237
return retry ( async ( ) => {
238
238
return this . extensionIpc . getWorkspaceAuthInfo ( { workspaceId : username , gitpodHost : this . options . host } ) . catch ( e => {
239
+ if ( e instanceof ClientError ) {
240
+ if ( e . code === Status . FAILED_PRECONDITION && e . message . includes ( 'gitpod host mismatch' ) ) {
241
+ throw new FailedToProxyError ( 'GitpodHostMismatch' , e ) ;
242
+ } else if ( e . code === Status . INTERNAL && e . message . includes ( 'no access token found' ) ) {
243
+ throw new FailedToProxyError ( 'NoAccessTokenFound' , e ) ;
244
+ }
245
+ }
239
246
throw new FailedToProxyError ( 'FailedToGetAuthInfo' , e ) ;
240
247
} ) ;
241
248
} , 200 , 50 ) ;
0 commit comments