Skip to content

Commit c425a3e

Browse files
committed
Fix #221: Occasional init hang in LanguageServer
This change fixes an issue in the LanguageServer where the length of time that it takes to evaluate the extension API script can cause the "initialize" request to not complete. This leaves the VS Code language server client in an initializing state where no language features will work for the rest of the session. The fix is to execute the extension API script after the "initialize" handler has been registered.
1 parent f58c82b commit c425a3e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ public LanguageServer(HostDetails hostDetails, ChannelBase serverChannel)
7474

7575
protected override void Initialize()
7676
{
77-
// Initialize the extension service
78-
// TODO: This should be made awaited once Initialize is async!
79-
this.editorSession.ExtensionService.Initialize(
80-
this.editorOperations).Wait();
81-
8277
// Register all supported message types
8378

8479
this.SetRequestHandler(InitializeRequest.Type, this.HandleInitializeRequest);
@@ -107,6 +102,11 @@ protected override void Initialize()
107102
this.SetRequestHandler(InvokeExtensionCommandRequest.Type, this.HandleInvokeExtensionCommandRequest);
108103

109104
this.SetRequestHandler(DebugAdapterMessages.EvaluateRequest.Type, this.HandleEvaluateRequest);
105+
106+
// Initialize the extension service
107+
// TODO: This should be made awaited once Initialize is async!
108+
this.editorSession.ExtensionService.Initialize(
109+
this.editorOperations).Wait();
110110
}
111111

112112
protected override async Task Shutdown()

0 commit comments

Comments
 (0)