Skip to content

Commit 7126165

Browse files
committed
Filter some error reports out
1 parent a0e7bcc commit 7126165

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/local-ssh/proxy.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ function getClientOptions(): ClientOptions {
4242
}
4343

4444
type FailedToProxyCode = 'SSH.AuthenticationFailed' | 'TUNNEL.AuthenticateSSHKeyFailed' | 'NoRunningInstance' | 'FailedToGetAuthInfo';
45+
46+
// IgnoredFailedCodes contains the failreCode that don't need to send error report
47+
const IgnoredFailedCodes: FailedToProxyCode[] = ['NoRunningInstance'];
48+
4549
class FailedToProxyError extends Error {
4650
constructor(public readonly failureCode: FailedToProxyCode, originError?: Error) {
4751
const msg = 'Failed to proxy connection: ' + failureCode;
@@ -135,12 +139,16 @@ class WebSocketSSHProxy {
135139
pipePromise = session.pipe(pipeSession);
136140
return {};
137141
}).catch(async err => {
142+
let sendErrorReport = true
138143
if (err instanceof FailedToProxyError) {
139144
this.flow.failureCode = err.failureCode;
145+
if (IgnoredFailedCodes.includes(err.failureCode)) {
146+
sendErrorReport = false
147+
}
140148
}
141149
await Promise.allSettled([
142150
this.sendUserStatusFlow('failed'),
143-
this.sendErrorReport(this.flow, err, 'failed to authenticate proxy with username: ' + e.username ?? '')
151+
sendErrorReport ? this.sendErrorReport(this.flow, err, 'failed to authenticate proxy with username: ' + e.username ?? '') : undefined,
144152
]);
145153
this.logService.error(err, 'failed to authenticate proxy with username: ' + e.username ?? '');
146154
await session.close(SshDisconnectReason.byApplication, err.toString(), err instanceof Error ? err : undefined);

src/services/localSSHService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ export interface ILocalSSHService {
2626

2727
type FailedToInitializeCode = 'Unknown' | 'LockFailed' | string;
2828

29+
// IgnoredFailedCodes contains the codes that don't need to send error report
30+
const IgnoredFailedCodes: FailedToInitializeCode[] = ['ENOSPC'];
31+
2932
export class LocalSSHService extends Disposable implements ILocalSSHService {
3033
public isSupportLocalSSH: boolean = false;
3134
public initialized!: Promise<void>;
@@ -74,14 +77,18 @@ export class LocalSSHService extends Disposable implements ILocalSSHService {
7477
});
7578
} catch (e) {
7679
this.logService.error(e, 'failed to initialize');
80+
let sendErrorReport = true;
7781
failureCode = 'Unknown';
7882
if (e?.code) {
7983
failureCode = e.code;
84+
sendErrorReport = !IgnoredFailedCodes.includes(e.code)
8085
}
8186
if (e?.message) {
8287
e.message = `Failed to initialize: ${e.message}`;
8388
}
84-
this.telemetryService.sendTelemetryException(e, { gitpodHost: this.hostService.gitpodHost, useLocalAPP });
89+
if (sendErrorReport) {
90+
this.telemetryService.sendTelemetryException(e, { gitpodHost: this.hostService.gitpodHost, useLocalAPP });
91+
}
8592
this.isSupportLocalSSH = false;
8693
}
8794
const flowData = this.flow ? this.flow : { gitpodHost: this.hostService.gitpodHost, userId: this.sessionService.safeGetUserId() };

0 commit comments

Comments
 (0)