Skip to content

Commit 4025455

Browse files
Ask for local app fallback when Timed out while waiting for handshake (#20)
Co-authored-by: Filip Troníček <[email protected]>
1 parent 7874856 commit 4025455

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/experiments.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class ExperimentalSettings {
3232
this.extensionVersion = new semver.SemVer(extensionVersion);
3333
}
3434

35-
async get<T>(key: string, userId?: string): Promise<T | undefined> {
35+
async get<T>(key: string, userId?: string, custom?: { [key: string]: string }): Promise<T | undefined> {
3636
const config = vscode.workspace.getConfiguration('gitpod');
3737
const values = config.inspect<T>(key.substring('gitpod.'.length));
3838
if (!values || !EXPERTIMENTAL_SETTINGS.includes(key)) {
@@ -48,22 +48,22 @@ export class ExperimentalSettings {
4848
return values.globalValue;
4949
}
5050

51-
const user = userId ? new configcatcommon.User(userId) : undefined;
51+
const user = userId ? new configcatcommon.User(userId, undefined, undefined, custom) : undefined;
5252
const configcatKey = key.replace(/\./g, '_'); // '.' are not allowed in configcat
5353
const experimentValue = (await this.configcatClient.getValueAsync(configcatKey, undefined, user)) as T | undefined;
5454

5555
return experimentValue ?? values.defaultValue;
5656
}
5757

58-
async inspect<T>(key: string, userId?: string): Promise<{ key: string; defaultValue?: T; globalValue?: T; experimentValue?: T } | undefined> {
58+
async inspect<T>(key: string, userId?: string, custom?: { [key: string]: string }): Promise<{ key: string; defaultValue?: T; globalValue?: T; experimentValue?: T } | undefined> {
5959
const config = vscode.workspace.getConfiguration('gitpod');
6060
const values = config.inspect<T>(key.substring('gitpod.'.length));
6161
if (!values || !EXPERTIMENTAL_SETTINGS.includes(key)) {
6262
this.logger.error(`Cannot inspect invalid experimental setting '${key}'`);
6363
return values;
6464
}
6565

66-
const user = userId ? new configcatcommon.User(userId) : undefined;
66+
const user = userId ? new configcatcommon.User(userId, undefined, undefined, custom) : undefined;
6767
const configcatKey = key.replace(/\./g, '_'); // '.' are not allowed in configcat
6868
const experimentValue = (await this.configcatClient.getValueAsync(configcatKey, undefined, user)) as T | undefined;
6969

src/remoteConnector.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ export default class RemoteConnector extends Disposable {
566566
}).connect({
567567
host: sshDestInfo.hostName,
568568
username: sshDestInfo.user,
569+
readyTimeout: 40000,
569570
authHandler(_methodsLeft, _partialSuccess, _callback) {
570571
return {
571572
type: 'password',
@@ -787,7 +788,7 @@ export default class RemoteConnector extends Disposable {
787788

788789
// Only use experiment for SaaS
789790
const forceUseLocalApp = getServiceURL(params.gitpodHost) === 'https://gitpod.io'
790-
? (await this.experiments.get<boolean>('gitpod.remote.useLocalApp', session.account.id))!
791+
? (await this.experiments.get<boolean>('gitpod.remote.useLocalApp', session.account.id, { gitpodHost: params.gitpodHost }))!
791792
: vscode.workspace.getConfiguration('gitpod').get<boolean>('remote.useLocalApp')!;
792793
const userOverride = isUserOverrideSetting('gitpod.remote.useLocalApp');
793794
let sshDestination: string | undefined;
@@ -808,7 +809,13 @@ export default class RemoteConnector extends Disposable {
808809
this.telemetry.sendRawTelemetryEvent('vscode_desktop_ssh', { kind: 'gateway', status: 'failed', reason: e.toString(), ...params, gitpodVersion: gitpodVersion.raw, userOverride, openSSHVersion });
809810
if (e instanceof NoSSHGatewayError) {
810811
this.logger.error('No SSH gateway:', e);
811-
vscode.window.showWarningMessage(`${e.host} does not support [direct SSH access](https://github.com/gitpod-io/gitpod/blob/main/install/installer/docs/workspace-ssh-access.md), connecting via the deprecated SSH tunnel over WebSocket.`);
812+
const ok = 'OK';
813+
await vscode.window.showWarningMessage(`${e.host} does not support [direct SSH access](https://github.com/gitpod-io/gitpod/blob/main/install/installer/docs/workspace-ssh-access.md), connecting via the deprecated SSH tunnel over WebSocket.`, ok);
814+
// Do nothing and continue execution
815+
} else if (e instanceof SSHError && e.message === 'Timed out while waiting for handshake') {
816+
this.logger.error('SSH test connection error:', e);
817+
const ok = 'OK';
818+
await vscode.window.showWarningMessage(`Timed out while waiting for the SSH handshake. It's possible, that SSH connections on port 22 are blocked, or your network is too slow. Connecting via the deprecated SSH tunnel over WebSocket instead.`, ok);
812819
// Do nothing and continue execution
813820
} else if (e instanceof NoRunningInstanceError) {
814821
this.logger.error('No Running instance:', e);

0 commit comments

Comments
 (0)