From 3f56706e057146bacdb2967d12f667fa40fe16dd Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 20 May 2021 11:49:06 -0700 Subject: [PATCH] Set server receiver to `initialized` at the end of the `initialize` request (#589) --- src/Server/LanguageServer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Server/LanguageServer.cs b/src/Server/LanguageServer.cs index 9e0aaae9b..6838a50c0 100644 --- a/src/Server/LanguageServer.cs +++ b/src/Server/LanguageServer.cs @@ -313,10 +313,15 @@ await LanguageProtocolEventingHelper.Run( ).ConfigureAwait(false); + // Allow the server receiver to start processing incoming notifications and requests. It + // is necessary to do this now, and not in the Initialized handler, because otherwise + // clients can enter a race with the receiver and have their notifications and requests + // erroneously dropped. + _serverReceiver.Initialized(); + // TODO: if (_clientVersion == ClientVersion.Lsp2) { - _serverReceiver.Initialized(); _initializeComplete.OnNext(result); _initializeComplete.OnCompleted(); } @@ -328,7 +333,6 @@ public Task Handle(InitializedParams @params, CancellationToken token) { if (_clientVersion == ClientVersion.Lsp3) { - _serverReceiver.Initialized(); _initializeComplete.OnNext(ServerSettings); _initializeComplete.OnCompleted(); }