Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a66b7e3

Browse files
editor/code: Remove unused sendRequestWithRetry
1 parent fd31006 commit a66b7e3

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

editors/code/src/util.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as lc from "vscode-languageclient/node";
21
import * as vscode from "vscode";
32
import { strict as nativeAssert } from "assert";
43
import { exec, ExecOptions, spawnSync } from "child_process";
@@ -57,41 +56,6 @@ export const log = new (class {
5756
}
5857
})();
5958

60-
export async function sendRequestWithRetry<TParam, TRet>(
61-
client: lc.LanguageClient,
62-
reqType: lc.RequestType<TParam, TRet, unknown>,
63-
param: TParam,
64-
token?: vscode.CancellationToken
65-
): Promise<TRet> {
66-
// The sequence is `10 * (2 ** (2 * n))` where n is 1, 2, 3...
67-
for (const delay of [40, 160, 640, 2560, 10240, null]) {
68-
try {
69-
return await (token
70-
? client.sendRequest(reqType, param, token)
71-
: client.sendRequest(reqType, param));
72-
} catch (error: unknown) {
73-
if (delay === null) {
74-
log.warn("LSP request timed out", { method: reqType.method, param, error });
75-
throw error;
76-
}
77-
78-
if (error instanceof lc.ResponseError) {
79-
switch (error.code) {
80-
case lc.LSPErrorCodes.RequestCancelled:
81-
throw error;
82-
case lc.LSPErrorCodes.ContentModified:
83-
await sleep(delay);
84-
continue;
85-
}
86-
}
87-
88-
log.warn("LSP request failed", { method: reqType.method, param, error });
89-
throw error;
90-
}
91-
}
92-
throw "unreachable";
93-
}
94-
9559
export function sleep(ms: number) {
9660
return new Promise((resolve) => setTimeout(resolve, ms));
9761
}

0 commit comments

Comments
 (0)