Skip to content

Commit 064b4b8

Browse files
committed
clean up language clients after they stop
- avoid retaining stopped clients - dispose clients when startup fails
1 parent 7984bee commit 064b4b8

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/languageService.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,17 @@ export class LanguageService implements Disposable {
202202
client = new LanguageClient('r', 'R Language Server', tcpServerOptions, clientOptions);
203203
}
204204

205-
extensionContext.subscriptions.push(client);
206-
await client.start();
207-
return client;
205+
try {
206+
await client.start();
207+
return client;
208+
} catch (error) {
209+
try {
210+
await client.dispose();
211+
} catch {
212+
// A failed start may leave no active connection to stop.
213+
}
214+
throw error;
215+
}
208216
}
209217

210218

0 commit comments

Comments
 (0)