Skip to content

Commit dc627cf

Browse files
fix: end existing clients on new start and properly await stop (#264)
* end existing clients on new start and properly await stop * remove get client warning so it doesn't warn on startup --------- Co-authored-by: Katrina Liu <katrina@semgrep.com>
1 parent 3427c1d commit dc627cf

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/env.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ export class Environment {
167167
}
168168

169169
get client(): LanguageClient | null {
170-
if (!this._client) {
171-
window.showWarningMessage("Semgrep Language Server not active");
172-
}
173170
return this._client;
174171
}
175172

src/lsp.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ async function start(env: Environment): Promise<void> {
220220
// TODO: Remove when semgrep is no longer experimental on Windows.
221221
if (process.platform === "win32") process.env.SEMGREP_FORCE_INSTALL = "1";
222222

223+
if (env.client) {
224+
env.logger.log("Language client already running, stopping it...");
225+
await env.client.stop();
226+
env.client = null;
227+
}
228+
223229
// Compute LSP server and client options
224230
const [serverOptions, clientOptions] = await lspOptions(env);
225231

@@ -266,10 +272,7 @@ async function stop(env: Environment | null): Promise<void> {
266272
if (!client) {
267273
return;
268274
}
269-
await client.sendRequest("shutdown");
270-
env?.logger.log("Exiting");
271-
await client.sendNotification("exit");
272-
client.stop();
275+
await client.stop();
273276
env?.logger.log("Language client stopped...");
274277
}
275278

0 commit comments

Comments
 (0)