Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/util.ts')
| -rw-r--r-- | editors/code/src/util.ts | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index b6b779e266..38ce676157 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts @@ -1,7 +1,6 @@ -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"; +import { exec, type ExecOptions, spawnSync } from "child_process"; import { inspect } from "util"; export function assert(condition: boolean, explanation: string): asserts condition { @@ -57,37 +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) { - if (delay === null) { - log.warn("LSP request timed out", { method: reqType.method, param, error }); - throw error; - } - if (error.code === lc.LSPErrorCodes.RequestCancelled) { - throw error; - } - - if (error.code !== lc.LSPErrorCodes.ContentModified) { - log.warn("LSP request failed", { method: reqType.method, param, error }); - throw error; - } - await sleep(delay); - } - } - throw "unreachable"; -} - export function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } @@ -146,7 +114,7 @@ export function setContextValue(key: string, value: any): Thenable<void> { * underlying async function. */ export function memoizeAsync<Ret, TThis, Param extends string>( - func: (this: TThis, arg: Param) => Promise<Ret> + func: (this: TThis, arg: Param) => Promise<Ret>, ) { const cache = new Map<string, Ret>(); |