Skip to content

Commit b0449b8

Browse files
committed
Websocket emit error after maxRetries
1 parent 22fb8eb commit b0449b8

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/internalApi.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,13 @@ class GitpodServerApi extends vscode.Disposable {
3333
const factory = new JsonRpcProxyFactory<GitpodServer>();
3434
this.service = new GitpodServiceImpl<GitpodClient, GitpodServer>(factory.createProxy());
3535

36+
const maxRetries = 3;
3637
const webSocket = new ReconnectingWebSocket(`${serviceUrl.replace('https', 'wss')}/api/v1`, undefined, {
3738
maxReconnectionDelay: 10000,
3839
minReconnectionDelay: 1000,
3940
reconnectionDelayGrowFactor: 1.5,
4041
connectionTimeout: 10000,
41-
maxRetries: 3,
42+
maxRetries,
4243
debug: false,
4344
startClosed: false,
4445
WebSocket: class extends WebSocket {
@@ -54,7 +55,11 @@ class GitpodServerApi extends vscode.Disposable {
5455
}
5556
}
5657
});
57-
webSocket.onerror = (e: ErrorEvent) => this.onErrorEmitter.fire(e.error);
58+
webSocket.onerror = (e: ErrorEvent) => {
59+
if (webSocket.retryCount >= maxRetries ) {
60+
this.onErrorEmitter.fire(e.error);
61+
}
62+
};
5863

5964
doListen({
6065
webSocket: (webSocket as any),

src/remoteConnector.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,9 +1024,7 @@ export default class RemoteConnector extends Disposable {
10241024
throw new Error('No Gitpod session available');
10251025
}
10261026

1027-
const workspaceInfo = await retry(async () => {
1028-
return await withServerApi(session!.accessToken, connectionInfo.gitpodHost, service => service.server.getWorkspace(connectionInfo.workspaceId), this.logger);
1029-
}, 500, 3);
1027+
const workspaceInfo = await withServerApi(session!.accessToken, connectionInfo.gitpodHost, service => service.server.getWorkspace(connectionInfo.workspaceId), this.logger);
10301028

10311029
if (workspaceInfo.latestInstance?.status?.phase !== 'running') {
10321030
throw new NoRunningInstanceError(connectionInfo.workspaceId, workspaceInfo.latestInstance?.status?.phase);

0 commit comments

Comments
 (0)