Skip to content

Commit 4e8110f

Browse files
committed
fix: allow disposing during preparation phase
1 parent 025a8d0 commit 4e8110f

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"jest-environment-jsdom": "^28.1.3",
6666
"js-cleanup": "^1.2.0",
6767
"monaco-languageclient": "^2.1.0",
68+
"once": "^1.4.0",
6869
"proxy-polyfill": "^0.3.2",
6970
"recast": "^0.21.1",
7071
"rollup": "2.77.0",

src/languageClient.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import delay from 'delay'
99
import { CancellationToken, Emitter, NotificationType, RequestType, Event, LogMessageNotification } from 'vscode-languageserver-protocol'
1010
import * as vscode from 'vscode'
11+
import once from 'once'
1112
import { updateServices } from './services'
1213
import createLanguageClient from './createLanguageClient'
1314
import { WillShutdownParams } from './customRequests'
@@ -138,13 +139,6 @@ export class LanguageClientManager implements LanguageClient {
138139
}
139140

140141
public async start (): Promise<void> {
141-
try {
142-
await loadExtensionConfigurations([this.id], this.useMutualizedProxy)
143-
} catch (error) {
144-
monaco.errorHandler.onUnexpectedError(new Error('[LSP] Unable to load extension configuration', {
145-
cause: error as Error
146-
}))
147-
}
148142
let started = false
149143
let attempt = 0
150144
while (
@@ -170,7 +164,19 @@ export class LanguageClientManager implements LanguageClient {
170164
}
171165
}
172166

167+
private prepare = once(async () => {
168+
try {
169+
await loadExtensionConfigurations([this.id], this.useMutualizedProxy)
170+
} catch (error) {
171+
monaco.errorHandler.onUnexpectedError(new Error('[LSP] Unable to load extension configuration', {
172+
cause: error as Error
173+
}))
174+
}
175+
})
176+
173177
private async _start (): Promise<void> {
178+
await this.prepare()
179+
174180
const onServerResponse = new Emitter<void>()
175181

176182
const languageClient = await createLanguageClient(

0 commit comments

Comments
 (0)