From 47e4f46df40aef0f07e5b3efebe13e8698b12fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20Ch=C3=A9ramy?= Date: Wed, 14 Oct 2026 18:35:07 +0200 Subject: [PATCH] fix: do not send didSave notification once the client is disposed The InitializeTextDocumentFeature awaits writeFile before sending the didSave notification. If the manager is disposed (or the client stopped) in the meantime, languageClient is undefined and sendNotification throws "Cannot read properties of undefined (reading 'sendNotification')" as an unhandled rejection. --- src/extensions.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extensions.ts b/src/extensions.ts index a77de77..423c6db 100644 --- a/src/extensions.ts +++ b/src/extensions.ts @@ -88,6 +88,11 @@ export class InitializeTextDocumentFeature implements StaticFeature { languageClient ) + // The client may have been disposed or stopped while the file was being written + if (languageClient.languageClient == null) { + return + } + // Always send notification even if the server doesn't support it (because csharp register the didSave feature too late) await languageClient.sendNotification(DidSaveTextDocumentNotification.type, { textDocument: {