diff options
Diffstat (limited to 'editors/code/src/ctx.ts')
-rw-r--r-- | editors/code/src/ctx.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/editors/code/src/ctx.ts b/editors/code/src/ctx.ts index ca4319064..75b3542f4 100644 --- a/editors/code/src/ctx.ts +++ b/editors/code/src/ctx.ts | |||
@@ -61,6 +61,21 @@ export class Ctx { | |||
61 | pushCleanup(d: { dispose(): any }) { | 61 | pushCleanup(d: { dispose(): any }) { |
62 | this.extCtx.subscriptions.push(d); | 62 | this.extCtx.subscriptions.push(d); |
63 | } | 63 | } |
64 | |||
65 | async sendRequestWithRetry<R>(method: string, param: any): Promise<R> { | ||
66 | await this.client.onReady(); | ||
67 | const nRetries = 3; | ||
68 | for (let triesLeft = nRetries; ; triesLeft--) { | ||
69 | try { | ||
70 | return await this.client.sendRequest(method, param); | ||
71 | } catch (e) { | ||
72 | if (e.code === lc.ErrorCodes.ContentModified && triesLeft > 0) { | ||
73 | continue; | ||
74 | } | ||
75 | throw e; | ||
76 | } | ||
77 | } | ||
78 | } | ||
64 | } | 79 | } |
65 | 80 | ||
66 | export type Cmd = (...args: any[]) => any; | 81 | export type Cmd = (...args: any[]) => any; |