Skip to content

Commit a6df470

Browse files
theletterfclaude
andauthored
Fix multiple Vale process spawning issue (#79)
This fixes the regression of the issue originally resolved in PR #18, where multiple Vale processes would spawn and consume excessive CPU. The LSP-based rewrite (PR #41) removed the old safeguards. This commit adds proper client lifecycle management: - Check for existing client in activate() and stop it before creating new one - Improve deactivate() with async/await and error handling - Add logging for better debugging of client lifecycle This ensures only one vale-ls process runs at a time, preventing the CPU spike issues users were experiencing. Fixes: Issue with multiple Vale processes spawning Related: PR #18 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent a3bf103 commit a6df470

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/lsp.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ interface valeArgs {
9292
}
9393

9494
export async function activate(context: ExtensionContext) {
95+
// Prevent multiple activations - stop existing client if present
96+
if (client) {
97+
console.log("Vale language client already active, stopping existing client");
98+
try {
99+
await client.stop();
100+
} catch (error) {
101+
console.error("Error stopping existing client:", error);
102+
}
103+
}
104+
95105
let filePath = path.join(context.extensionPath, "vale-ls");
96106

97107
// Handle Windows
@@ -214,9 +224,15 @@ export async function activate(context: ExtensionContext) {
214224
}
215225
}
216226

217-
export function deactivate(): Thenable<void> | undefined {
227+
export async function deactivate(): Promise<void> {
218228
if (!client) {
219-
return undefined;
229+
return;
230+
}
231+
232+
try {
233+
await client.stop();
234+
console.log("Vale language server stopped");
235+
} catch (error) {
236+
console.error("Error stopping Vale language server:", error);
220237
}
221-
return client.stop();
222238
}

0 commit comments

Comments
 (0)