@@ -7,7 +7,7 @@ import { SshClient } from '@microsoft/dev-tunnels-ssh-tcp';
77import { NodeStream , SshClientCredentials , SshClientSession , SshDisconnectReason , SshServerSession , SshSessionConfiguration , Stream , WebSocketStream } from '@microsoft/dev-tunnels-ssh' ;
88import { importKey , importKeyBytes } from '@microsoft/dev-tunnels-ssh-keys' ;
99import { 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' ;
1111import { retry } from '../common/async' ;
1212import { WebSocket } from 'ws' ;
1313import * as stream from 'stream' ;
@@ -41,7 +41,7 @@ function getClientOptions(): ClientOptions {
4141 } ;
4242}
4343
44- type FailedToProxyCode = 'SSH.AuthenticationFailed' | 'TUNNEL.AuthenticateSSHKeyFailed' | 'NoRunningInstance' | 'FailedToGetAuthInfo' ;
44+ type FailedToProxyCode = 'SSH.AuthenticationFailed' | 'TUNNEL.AuthenticateSSHKeyFailed' | 'NoRunningInstance' | 'FailedToGetAuthInfo' | 'GitpodHostMismatch' | 'NoAccessTokenFound' ;
4545
4646// IgnoredFailedCodes contains the failreCode that don't need to send error report
4747const IgnoredFailedCodes : FailedToProxyCode [ ] = [ 'NoRunningInstance' ] ;
@@ -139,11 +139,11 @@ class WebSocketSSHProxy {
139139 pipePromise = session . pipe ( pipeSession ) ;
140140 return { } ;
141141 } ) . catch ( async err => {
142- let sendErrorReport = true
142+ let sendErrorReport = true ;
143143 if ( err instanceof FailedToProxyError ) {
144144 this . flow . failureCode = err . failureCode ;
145145 if ( IgnoredFailedCodes . includes ( err . failureCode ) ) {
146- sendErrorReport = false
146+ sendErrorReport = false ;
147147 }
148148 }
149149 await Promise . allSettled ( [
@@ -236,6 +236,13 @@ class WebSocketSSHProxy {
236236 async retryGetWorkspaceInfo ( username : string ) {
237237 return retry ( async ( ) => {
238238 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+ }
239246 throw new FailedToProxyError ( 'FailedToGetAuthInfo' , e ) ;
240247 } ) ;
241248 } , 200 , 50 ) ;
0 commit comments