Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LSP] initialized seems to be sent too eagerly #1245

Open
mickaelistria opened this issue Jul 11, 2018 · 0 comments
Open

[LSP] initialized seems to be sent too eagerly #1245

mickaelistria opened this issue Jul 11, 2018 · 0 comments

Comments

@mickaelistria
Copy link

In the integration with Eclipse IDE, in automated tests (when things go crazy fast), we're hit by the fact that the Omnisharp-Roslyn language server sends initilized too early without being ready to handle requests.
The symptom is that we wait to receive initialized before sending other requests, but if we send them just after, those requests seem ignored.
This sequence of messages is the hint I take to conclude (maybe erroneously) that initialized is sent too early

> {"jsonrpc":"2.0","id":"1","method":"initialize","params":{"processId":15628,"rootPath":"/home/mistria/junit-workspace/csproj_org.eclipse.acute.tests.TestLSPIntegration_1531293766800/","rootUri":"file:///home/mistria/junit-workspace/csproj_org.eclipse.acute.tests.TestLSPIntegration_1531293766800/","capabilities":{"workspace":{"applyEdit":true,"symbol":{},"executeCommand":{"dynamicRegistration":true},"workspaceFolders":true},"textDocument":{"synchronization":{"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"completionItem":{"snippetSupport":true}},"hover":{},"signatureHelp":{},"references":{},"documentHighlight":{},"documentSymbol":{},"formatting":{},"rangeFormatting":{},"definition":{},"codeAction":{},"codeLens":{},"documentLink":{},"rename":{}}},"clientName":"Eclipse IDE","trace":"off"}}< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"Starting server..."}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"Added handlers... waiting for initialize..."}}

< {"protocolVersion":"2.0","id":"1","result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":true}},"hoverProvider":true,"completionProvider":{"resolveProvider":false},"signatureHelpProvider":{},"definitionProvider":true,"referencesProvider":false,"documentHighlightProvider":false,"documentSymbolProvider":true,"workspaceSymbolProvider":false,"codeActionProvider":false,"documentFormattingProvider":false,"documentRangeFormattingProvider":false,"renameProvider":true,"experimental":{}}}}

> {"jsonrpc":"2.0","method":"initialized","params":{}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[dbug]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Finding descriptor for initialized"}}

> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///home/mistria/junit-workspace/csproj_org.eclipse.acute.tests.TestLSPIntegration_1531293766800/Program.cs","languageId":"cs","version":1,"text":"using System;\r\n\r\nnamespace ConsoleDotNet\r\n{\r\n    class Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n\t\t\tint n \u003d 4;\r\n\t\t\tn++;\r\n            Console.WriteLine(\"Hello World!\" + n);\r\n        }\r\n    }\r\n}\r\n"}}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[dbug]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Finding descriptor for textDocument/didOpen"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Created attribute cs::file:///home/mistria/junit-workspace/csproj_org.eclipse.acute.tests.TestLSPIntegration_1531293766800/Program.cs"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Looking for handler for method textDocument/didOpen"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Checking handler textDocument/didOpen:OmniSharp.LanguageServerProtocol.Handlers.TextDocumentSyncHandler"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Registration options OmniSharp.Extensions.LanguageServer.Models.TextDocumentRegistrationOptions"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Document Selector [**/*.cake]"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Checking handler textDocument/didOpen:OmniSharp.LanguageServerProtocol.Handlers.TextDocumentSyncHandler"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Registration options OmniSharp.Extensions.LanguageServer.Models.TextDocumentRegistrationOptions"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Document Selector [**/*.cs], [**/*.csx]"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"[trce]: OmniSharp.Extensions.LanguageServer.LspRequestRouter\n        Handler Selected: OmniSharp.LanguageServerProtocol.Handlers.TextDocumentSyncHandler via [**/*.cs], [**/*.csx] (targeting System.RuntimeType)"}}

< {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"initialized..."}}

As you can see the {"protocolVersion":"2.0","method":"window/logMessage","params":{"type":4,"message":"initialized..."}} comes later while the client (according to the spec) expect initialization to be complete after 1st response.
For some operations like documentChange, it makes that messages can be sent between the declared readiness and the actual readiness, making the server ignore those messages and building an erroneous state of the document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant