diff options
Diffstat (limited to 'editors/code/src/util.ts')
-rw-r--r-- | editors/code/src/util.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts index 2f18f85a3..68c2a94d0 100644 --- a/editors/code/src/util.ts +++ b/editors/code/src/util.ts | |||
@@ -20,21 +20,21 @@ export const log = { | |||
20 | } | 20 | } |
21 | }; | 21 | }; |
22 | 22 | ||
23 | export async function sendRequestWithRetry<R>( | 23 | export async function sendRequestWithRetry<TParam, TRet>( |
24 | client: lc.LanguageClient, | 24 | client: lc.LanguageClient, |
25 | method: string, | 25 | reqType: lc.RequestType<TParam, TRet, unknown>, |
26 | param: unknown, | 26 | param: TParam, |
27 | token?: vscode.CancellationToken, | 27 | token?: vscode.CancellationToken, |
28 | ): Promise<R> { | 28 | ): Promise<TRet> { |
29 | for (const delay of [2, 4, 6, 8, 10, null]) { | 29 | for (const delay of [2, 4, 6, 8, 10, null]) { |
30 | try { | 30 | try { |
31 | return await (token | 31 | return await (token |
32 | ? client.sendRequest(method, param, token) | 32 | ? client.sendRequest(reqType, param, token) |
33 | : client.sendRequest(method, param) | 33 | : client.sendRequest(reqType, param) |
34 | ); | 34 | ); |
35 | } catch (error) { | 35 | } catch (error) { |
36 | if (delay === null) { | 36 | if (delay === null) { |
37 | log.error("LSP request timed out", { method, param, error }); | 37 | log.error("LSP request timed out", { method: reqType.method, param, error }); |
38 | throw error; | 38 | throw error; |
39 | } | 39 | } |
40 | 40 | ||
@@ -43,7 +43,7 @@ export async function sendRequestWithRetry<R>( | |||
43 | } | 43 | } |
44 | 44 | ||
45 | if (error.code !== lc.ErrorCodes.ContentModified) { | 45 | if (error.code !== lc.ErrorCodes.ContentModified) { |
46 | log.error("LSP request failed", { method, param, error }); | 46 | log.error("LSP request failed", { method: reqType.method, param, error }); |
47 | throw error; | 47 | throw error; |
48 | } | 48 | } |
49 | 49 | ||