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

Commit fd31006

Browse files
editor/code: Assert types in catch in sendRequestWithRetry() properly
1 parent 2f6d545 commit fd31006

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

editors/code/src/util.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,24 @@ export async function sendRequestWithRetry<TParam, TRet>(
6969
return await (token
7070
? client.sendRequest(reqType, param, token)
7171
: client.sendRequest(reqType, param));
72-
} catch (error) {
72+
} catch (error: unknown) {
7373
if (delay === null) {
7474
log.warn("LSP request timed out", { method: reqType.method, param, error });
7575
throw error;
7676
}
77-
if (error.code === lc.LSPErrorCodes.RequestCancelled) {
78-
throw error;
79-
}
8077

81-
if (error.code !== lc.LSPErrorCodes.ContentModified) {
82-
log.warn("LSP request failed", { method: reqType.method, param, error });
83-
throw error;
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+
}
8486
}
85-
await sleep(delay);
87+
88+
log.warn("LSP request failed", { method: reqType.method, param, error });
89+
throw error;
8690
}
8791
}
8892
throw "unreachable";

0 commit comments

Comments
 (0)