Skip to content

Commit 7c452c8

Browse files
committed
Remove old workaround
1 parent 05e1655 commit 7c452c8

File tree

3 files changed

+24
-58
lines changed

3 files changed

+24
-58
lines changed

src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export async function activate(context: vscode.ExtensionContext) {
8080
const hostService = new HostService(context, notificationService, logger);
8181
context.subscriptions.push(hostService);
8282

83-
const sessionService = new SessionService(hostService, logger, telemetryService);
83+
const sessionService = new SessionService(hostService, logger);
8484
context.subscriptions.push(sessionService);
8585

8686
const remoteService = new RemoteService(context, hostService, sessionService, notificationService, telemetryService, logger);
@@ -119,7 +119,7 @@ export async function activate(context: vscode.ExtensionContext) {
119119
commandManager.register(new InstallLocalExtensionsOnRemoteCommand(remoteService));
120120
commandManager.register(new ExportLogsCommand(context, context.logUri, notificationService, telemetryService, logger, hostService));
121121
// Backwards compatibility with older gitpod-remote extensions
122-
commandManager.register({ id: 'gitpod.api.autoTunnel', execute: () => {} });
122+
commandManager.register({ id: 'gitpod.api.autoTunnel', execute: () => { } });
123123

124124
if (!context.globalState.get<boolean>(FIRST_INSTALL_KEY, false)) {
125125
context.globalState.update(FIRST_INSTALL_KEY, true);

src/publicApi.ts

Lines changed: 21 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { timeout } from './common/async';
1616
import { MetricsReporter, getConnectMetricsInterceptor } from './metrics';
1717
import { ILogService } from './services/logService';
1818
import { WrapError } from './common/utils';
19-
import { ITelemetryService } from './common/telemetry';
2019

2120
function isTelemetryEnabled(): boolean {
2221
const TELEMETRY_CONFIG_ID = 'telemetry';
@@ -60,7 +59,6 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI {
6059
private readonly accessToken: string,
6160
private readonly gitpodHost: string,
6261
private readonly logger: ILogService,
63-
private readonly telemetryService: ITelemetryService
6462
) {
6563
super();
6664

@@ -97,70 +95,70 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI {
9795
}
9896

9997
async listWorkspaces(): Promise<Workspace[]> {
100-
return this._wrapError(this._workaroundGoAwayBug(async () => {
98+
return this._wrapError(async () => {
10199
const response = await this.workspaceService.listWorkspaces({});
102100
return response.result;
103-
}));
101+
});
104102
}
105103

106104
async getWorkspace(workspaceId: string, signal?: AbortSignal): Promise<Workspace> {
107-
return this._wrapError(this._workaroundGoAwayBug(async () => {
105+
return this._wrapError(async () => {
108106
const response = await this.workspaceService.getWorkspace({ workspaceId });
109107
return response.result!;
110-
}), { signal });
108+
}, { signal });
111109
}
112110

113111
async startWorkspace(workspaceId: string): Promise<Workspace> {
114-
return this._wrapError(this._workaroundGoAwayBug(async () => {
112+
return this._wrapError(async () => {
115113
const response = await this.workspaceService.startWorkspace({ workspaceId });
116114
return response.result!;
117-
}));
115+
});
118116
}
119117

120118
async stopWorkspace(workspaceId: string): Promise<Workspace> {
121-
return this._wrapError(this._workaroundGoAwayBug(async () => {
119+
return this._wrapError(async () => {
122120
const response = await this.workspaceService.stopWorkspace({ workspaceId });
123121
return response.result!;
124-
}));
122+
});
125123
}
126124

127125
async deleteWorkspace(workspaceId: string): Promise<void> {
128-
return this._wrapError(this._workaroundGoAwayBug(async () => {
126+
return this._wrapError(async () => {
129127
await this.workspaceService.deleteWorkspace({ workspaceId });
130-
}));
128+
});
131129
}
132130

133131
async getOwnerToken(workspaceId: string, signal?: AbortSignal): Promise<string> {
134-
return this._wrapError(this._workaroundGoAwayBug(async () => {
132+
return this._wrapError(async () => {
135133
const response = await this.workspaceService.getOwnerToken({ workspaceId });
136134
return response.token;
137-
}), { signal });
135+
}, { signal });
138136
}
139137

140138
async getSSHKeys(): Promise<SSHKey[]> {
141-
return this._wrapError(this._workaroundGoAwayBug(async () => {
139+
return this._wrapError(async () => {
142140
const response = await this.userService.listSSHKeys({});
143141
return response.keys;
144-
}));
142+
});
145143
}
146144

147145
async sendHeartbeat(workspaceId: string): Promise<void> {
148-
return this._wrapError(this._workaroundGoAwayBug(async () => {
146+
return this._wrapError(async () => {
149147
await this.ideClientService.sendHeartbeat({ workspaceId });
150-
}));
148+
});
151149
}
152150

153151
async sendDidClose(workspaceId: string): Promise<void> {
154-
return this._wrapError(this._workaroundGoAwayBug(async () => {
152+
return this._wrapError(async () => {
155153
await this.ideClientService.sendDidClose({ workspaceId });
156-
}));
154+
});
157155
}
158156

159157
async getAuthenticatedUser(): Promise<User | undefined> {
160-
return this._wrapError(this._workaroundGoAwayBug(async () => {
158+
return this._wrapError(async () => {
161159
const response = await this.userService.getAuthenticatedUser({});
162160
return response.user;
163-
}));
161+
});
164162
}
165163

166164
workspaceStatusStreaming(workspaceId: string) {
@@ -176,7 +174,7 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI {
176174
if (isDisposed) { return; }
177175

178176
try {
179-
const resp = await this._workaroundGoAwayBug(() => this.workspaceService.getWorkspace({ workspaceId }))();
177+
const resp = await this.workspaceService.getWorkspace({ workspaceId });
180178
if (isDisposed) { return; }
181179
emitter.fire(resp.result!.status!);
182180
} catch (err) {
@@ -225,15 +223,6 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI {
225223
return;
226224
}
227225
this.logger.error(`Error in streamWorkspaceStatus for ${workspaceId}`, e);
228-
229-
// Workaround https://github.com/bufbuild/connect-es/issues/680
230-
// Remove this once it's fixed upstream
231-
const message: string = e.stack || e.message || `${e}`;
232-
if (message.includes('New streams cannot be created after receiving a GOAWAY')) {
233-
this.telemetryService.sendTelemetryException(e);
234-
this.logger.error('Got GOAWAY bug, recreating connect client');
235-
this.createClients();
236-
}
237226
}
238227
}
239228

@@ -258,27 +247,6 @@ export class GitpodPublicApi extends Disposable implements IGitpodAPI {
258247
return callback().catch(onError);
259248
}
260249

261-
private _workaroundGoAwayBug<T>(callback: () => Promise<T>): () => Promise<T> {
262-
return async () => {
263-
try {
264-
return await callback();
265-
} catch (e) {
266-
// Workaround https://github.com/bufbuild/connect-es/issues/680
267-
// Remove this once it's fixed upstream
268-
const message: string = e.stack || e.message || `${e}`;
269-
if (message.includes('New streams cannot be created after receiving a GOAWAY')) {
270-
this.telemetryService.sendTelemetryException(e);
271-
this.logger.error('Got GOAWAY bug, recreating connect client');
272-
this.createClients();
273-
274-
return await callback();
275-
} else {
276-
throw e;
277-
}
278-
}
279-
};
280-
}
281-
282250
public override dispose() {
283251
super.dispose();
284252
for (const { dispose } of this.workspaceStatusStreamMap.values()) {

src/services/sessionService.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { IHostService } from './hostService';
99
import { GitpodPublicApi, IGitpodAPI } from '../publicApi';
1010
import { eventToPromise } from '../common/event';
1111
import { ILogService } from './logService';
12-
import { ITelemetryService } from '../common/telemetry';
1312
import { arrayEquals } from '../common/utils';
1413

1514
export class NoSignedInError extends Error {
@@ -72,7 +71,6 @@ export class SessionService extends Disposable implements ISessionService {
7271
constructor(
7372
private readonly hostService: IHostService,
7473
private readonly logger: ILogService,
75-
private readonly telemetryService: ITelemetryService
7674
) {
7775
super();
7876

@@ -187,7 +185,7 @@ export class SessionService extends Disposable implements ISessionService {
187185
throw new NoSignedInError();
188186
}
189187
if (!this._publicApi) {
190-
this._publicApi = new GitpodPublicApi(this.getGitpodToken(), this.hostService.gitpodHost, this.logger, this.telemetryService);
188+
this._publicApi = new GitpodPublicApi(this.getGitpodToken(), this.hostService.gitpodHost, this.logger);
191189
}
192190
return this._publicApi;
193191
}

0 commit comments

Comments
 (0)