Retry inlay hints on content modified error

This commit is contained in:
Aleksey Kladov 2019-12-30 22:18:16 +01:00
parent 08c5d157f9
commit 23bac12062
4 changed files with 22 additions and 17 deletions

View file

@ -61,6 +61,21 @@ export class Ctx {
pushCleanup(d: { dispose(): any }) {
this.extCtx.subscriptions.push(d);
}
async sendRequestWithRetry<R>(method: string, param: any): Promise<R> {
await this.client.onReady();
const nRetries = 3;
for (let triesLeft = nRetries; ; triesLeft--) {
try {
return await this.client.sendRequest(method, param);
} catch (e) {
if (e.code === lc.ErrorCodes.ContentModified && triesLeft > 0) {
continue;
}
throw e;
}
}
}
}
export type Cmd = (...args: any[]) => any;