Unnamed repository; edit this file 'description' to name the repository.
editor/code: Remove unused `sendRequestWithRetry`
Tetsuharu Ohzeki 2023-07-10
parent fd31006 · commit a66b7e3
-rw-r--r--editors/code/src/util.ts36
1 files changed, 0 insertions, 36 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index 688e3873ab..b6240234aa 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -1,4 +1,3 @@
-import * as lc from "vscode-languageclient/node";
import * as vscode from "vscode";
import { strict as nativeAssert } from "assert";
import { exec, ExecOptions, spawnSync } from "child_process";
@@ -57,41 +56,6 @@ export const log = new (class {
}
})();
-export async function sendRequestWithRetry<TParam, TRet>(
- client: lc.LanguageClient,
- reqType: lc.RequestType<TParam, TRet, unknown>,
- param: TParam,
- token?: vscode.CancellationToken
-): Promise<TRet> {
- // The sequence is `10 * (2 ** (2 * n))` where n is 1, 2, 3...
- for (const delay of [40, 160, 640, 2560, 10240, null]) {
- try {
- return await (token
- ? client.sendRequest(reqType, param, token)
- : client.sendRequest(reqType, param));
- } catch (error: unknown) {
- if (delay === null) {
- log.warn("LSP request timed out", { method: reqType.method, param, error });
- throw error;
- }
-
- if (error instanceof lc.ResponseError) {
- switch (error.code) {
- case lc.LSPErrorCodes.RequestCancelled:
- throw error;
- case lc.LSPErrorCodes.ContentModified:
- await sleep(delay);
- continue;
- }
- }
-
- log.warn("LSP request failed", { method: reqType.method, param, error });
- throw error;
- }
- }
- throw "unreachable";
-}
-
export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}