diff --git a/src/extension.ts b/src/extension.ts index 88e1e73..8aae7e5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -80,7 +80,7 @@ export async function activate(context: vscode.ExtensionContext) { const hostService = new HostService(context, notificationService, logger); context.subscriptions.push(hostService); - const sessionService = new SessionService(hostService, logger, telemetryService); + const sessionService = new SessionService(hostService, logger); context.subscriptions.push(sessionService); const remoteService = new RemoteService(context, hostService, sessionService, notificationService, telemetryService, logger); @@ -119,7 +119,7 @@ export async function activate(context: vscode.ExtensionContext) { commandManager.register(new InstallLocalExtensionsOnRemoteCommand(remoteService)); commandManager.register(new ExportLogsCommand(context, context.logUri, notificationService, telemetryService, logger, hostService)); // Backwards compatibility with older gitpod-remote extensions - commandManager.register({ id: 'gitpod.api.autoTunnel', execute: () => {} }); + commandManager.register({ id: 'gitpod.api.autoTunnel', execute: () => { } }); if (!context.globalState.get(FIRST_INSTALL_KEY, false)) { context.globalState.update(FIRST_INSTALL_KEY, true); diff --git a/src/publicApi.ts b/src/publicApi.ts index 6672cfc..2f1b7c2 100644 --- a/src/publicApi.ts +++ b/src/publicApi.ts @@ -16,7 +16,6 @@ import { timeout } from './common/async'; import { MetricsReporter, getConnectMetricsInterceptor } from './metrics'; import { ILogService } from './services/logService'; import { WrapError } from './common/utils'; -import { ITelemetryService } from './common/telemetry'; function isTelemetryEnabled(): boolean { const TELEMETRY_CONFIG_ID = 'telemetry'; @@ -60,7 +59,6 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI { private readonly accessToken: string, private readonly gitpodHost: string, private readonly logger: ILogService, - private readonly telemetryService: ITelemetryService ) { super(); @@ -97,70 +95,70 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI { } async listWorkspaces(): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { const response = await this.workspaceService.listWorkspaces({}); return response.result; - })); + }); } async getWorkspace(workspaceId: string, signal?: AbortSignal): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { const response = await this.workspaceService.getWorkspace({ workspaceId }); return response.result!; - }), { signal }); + }, { signal }); } async startWorkspace(workspaceId: string): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { const response = await this.workspaceService.startWorkspace({ workspaceId }); return response.result!; - })); + }); } async stopWorkspace(workspaceId: string): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { const response = await this.workspaceService.stopWorkspace({ workspaceId }); return response.result!; - })); + }); } async deleteWorkspace(workspaceId: string): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { await this.workspaceService.deleteWorkspace({ workspaceId }); - })); + }); } async getOwnerToken(workspaceId: string, signal?: AbortSignal): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { const response = await this.workspaceService.getOwnerToken({ workspaceId }); return response.token; - }), { signal }); + }, { signal }); } async getSSHKeys(): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { const response = await this.userService.listSSHKeys({}); return response.keys; - })); + }); } async sendHeartbeat(workspaceId: string): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { await this.ideClientService.sendHeartbeat({ workspaceId }); - })); + }); } async sendDidClose(workspaceId: string): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { await this.ideClientService.sendDidClose({ workspaceId }); - })); + }); } async getAuthenticatedUser(): Promise { - return this._wrapError(this._workaroundGoAwayBug(async () => { + return this._wrapError(async () => { const response = await this.userService.getAuthenticatedUser({}); return response.user; - })); + }); } workspaceStatusStreaming(workspaceId: string) { @@ -176,7 +174,7 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI { if (isDisposed) { return; } try { - const resp = await this._workaroundGoAwayBug(() => this.workspaceService.getWorkspace({ workspaceId }))(); + const resp = await this.workspaceService.getWorkspace({ workspaceId }); if (isDisposed) { return; } emitter.fire(resp.result!.status!); } catch (err) { @@ -225,15 +223,6 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI { return; } this.logger.error(`Error in streamWorkspaceStatus for ${workspaceId}`, e); - - // Workaround https://github.com/bufbuild/connect-es/issues/680 - // Remove this once it's fixed upstream - const message: string = e.stack || e.message || `${e}`; - if (message.includes('New streams cannot be created after receiving a GOAWAY')) { - this.telemetryService.sendTelemetryException(e); - this.logger.error('Got GOAWAY bug, recreating connect client'); - this.createClients(); - } } } @@ -258,27 +247,6 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI { return callback().catch(onError); } - private _workaroundGoAwayBug(callback: () => Promise): () => Promise { - return async () => { - try { - return await callback(); - } catch (e) { - // Workaround https://github.com/bufbuild/connect-es/issues/680 - // Remove this once it's fixed upstream - const message: string = e.stack || e.message || `${e}`; - if (message.includes('New streams cannot be created after receiving a GOAWAY')) { - this.telemetryService.sendTelemetryException(e); - this.logger.error('Got GOAWAY bug, recreating connect client'); - this.createClients(); - - return await callback(); - } else { - throw e; - } - } - }; - } - public override dispose() { super.dispose(); for (const { dispose } of this.workspaceStatusStreamMap.values()) { diff --git a/src/services/sessionService.ts b/src/services/sessionService.ts index e4bcf46..22b2955 100644 --- a/src/services/sessionService.ts +++ b/src/services/sessionService.ts @@ -9,7 +9,6 @@ import { IHostService } from './hostService'; import { GitpodPublicApi, IGitpodAPI } from '../publicApi'; import { eventToPromise } from '../common/event'; import { ILogService } from './logService'; -import { ITelemetryService } from '../common/telemetry'; import { arrayEquals } from '../common/utils'; export class NoSignedInError extends Error { @@ -72,7 +71,6 @@ export class SessionService extends Disposable implements ISessionService { constructor( private readonly hostService: IHostService, private readonly logger: ILogService, - private readonly telemetryService: ITelemetryService ) { super(); @@ -187,7 +185,7 @@ export class SessionService extends Disposable implements ISessionService { throw new NoSignedInError(); } if (!this._publicApi) { - this._publicApi = new GitpodPublicApi(this.getGitpodToken(), this.hostService.gitpodHost, this.logger, this.telemetryService); + this._publicApi = new GitpodPublicApi(this.getGitpodToken(), this.hostService.gitpodHost, this.logger); } return this._publicApi; }