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] Failed to handle notification initialize #1499

Closed
luizribeiro opened this issue May 18, 2019 · 8 comments
Closed

[LSP] Failed to handle notification initialize #1499

luizribeiro opened this issue May 18, 2019 · 8 comments
Labels

Comments

@luizribeiro
Copy link

luizribeiro commented May 18, 2019

I'm working on integrating vim-ale directly with omnisharp-roslyn's LSP server, as omnisharp-vim does not use the LSP as far as I can tell. This is so I can get auto-completion through vim-ale and LSP and not through omnicomplete itself.

In doing so, I've been getting errors back from omnisharp's LSP server. More specifically:

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":1,"message":"Failed to handle notification initialize - System.NullReferenceException: Object reference not set to an instance of an object\n  at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.OmniSharp.Extensions.Embedded.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle (OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams request, System.Threading.CancellationToken token) [0x0022d] in <c33e73e38fa14bf293bda2f62d3759c4>:0 \n  at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, OmniSharp.Extensions.Embedded.MediatR.RequestHandlerDelegate`1[TResponse] next) [0x000e1] in <c33e73e38fa14bf293bda2f62d3759c4>:0 \n  at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest (OmniSharp.Extensions.JsonRpc.IHandlerDescriptor descriptor, OmniSharp.Extensions.JsonRpc.Server.Request request) [0x002e2] in <c33e73e38fa14bf293bda2f62d3759c4>:0 "}}Content-Length: 129

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Finished: Routing Request (1) initialize in 1000ms"}}Content-Length: 1158

{"jsonrpc":"2.0","id":"1","error":{"code":-32602,"message":"Internal Error - System.NullReferenceException: Object reference not set to an instance of an object\n  at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.OmniSharp.Extensions.Embedded.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle (OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams request, System.Threading.CancellationToken token) [0x0022d] in <c33e73e38fa14bf293bda2f62d3759c4>:0 \n  at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, OmniSharp.Extensions.Embedded.MediatR.RequestHandlerDelegate`1[TResponse] next) [0x000e1] in <c33e73e38fa14bf293bda2f62d3759c4>:0 \n  at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest (OmniSharp.Extensions.JsonRpc.IHandlerDescriptor descriptor, OmniSharp.Extensions.JsonRpc.Server.Request request) [0x002e2] in <c33e73e38fa14bf293bda2f62d3759c4>:0 "}}

In other words, this is the exception that omnisharp-roslyn is giving me during initialization:

System.NullReferenceException: Object reference not set to an instance of an object
  at OmniSharp.Extensions.LanguageServer.Server.LanguageServer.OmniSharp.Extensions.Embedded.MediatR.IRequestHandler<OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams,OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeResult>.Handle (OmniSharp.Extensions.LanguageServer.Protocol.Models.InitializeParams request, System.Threading.CancellationToken token) [0x0022d] in <c33e73e38fa14bf293bda2f62d3759c4>:0 
  at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2[TRequest,TResponse].Handle (TRequest request, System.Threading.CancellationToken cancellationToken, OmniSharp.Extensions.Embedded.MediatR.RequestHandlerDelegate`1[TResponse] next) [0x000e1] in <c33e73e38fa14bf293bda2f62d3759c4>:0 
  at OmniSharp.Extensions.LanguageServer.Server.LspRequestRouter.RouteRequest (OmniSharp.Extensions.JsonRpc.IHandlerDescriptor descriptor, OmniSharp.Extensions.JsonRpc.Server.Request request) [0x002e2] in <c33e73e38fa14bf293bda2f62d3759c4>:0

For reference, this seems to be the command that vim-ale is sending to initialize the LSP:

{"method": "initialize", "jsonrpc": "2.0", "id": 1, "params": {"initializationOptions": {}, "rootUri": "file:///Users/luiz/projects/mgsb", "capabilities": {}, "rootPath": "/Users/luiz/projects/mgsb", "processId": 28524}}

Any idea what's up?

@bjorkstromm
Copy link
Member

@luizribeiro I think this is most likely because you don't send any client capabilities in your initialization request. Try to add at least support for text synchronization in your client implementation.

@luizribeiro
Copy link
Author

luizribeiro commented May 19, 2019

Thanks @mholo65, you are right! Looks like vim-ale doesn't send any capabilities because of a TODO that was left behind:

https://github.com/w0rp/ale/blob/3b7c86e401eb488acd8713f7c9ee81344095080d/autoload/ale/lsp/message.vim#L32-L40

Aren't all these fields optional on the LSP spec?

LSP should announce the capabilities it supports, but this is the first server I encounter that doesn't work with vim-ale because of this.

Either way, sending this as the capabilities made me get past the initialize message:

{  
   "workspace":{},
   "textDocument":{  
      "completion":{  
         "completionItem":{  
            "snippetSupport":false
         }
      }
   }
}

When I tried sending the text synchronization, I ran into #1403.

@w0rp
Copy link

w0rp commented May 20, 2019

Some capabilities are now sent by ALE, but you should also allow clients to connect to the server without sending any capabilities. All of the keys are optional.

@bjorkstromm
Copy link
Member

@w0rp yes, that’s a bug in the LSP implementation we are using. We are currently seeing other issues regarding initialization (and capabilities) and will put this on the list of things to do. //cc @david-driscoll

@bjorkstromm
Copy link
Member

Tracking fix here OmniSharp/csharp-language-server-protocol#141

@filipw filipw added the lsp label Jun 4, 2019
@david-driscoll
Copy link
Member

This should be fixed via OmniSharp/csharp-language-server-protocol#147

@rcjsuen
Copy link

rcjsuen commented Jul 24, 2019

Just got hit by this using omnisharp-mono.tar.gz from v1.34.0. I guess the fix hasn't been incorporated here yet.

I worked around it by adding "workspace": {} to my request. Thank you @luizribeiro for sharing your code.

@luizribeiro
Copy link
Author

I'm pretty sure we can close this. I've been using omnisharp-roslyn successfully with vim-ale.

Thanks for all your work on this!

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

No branches or pull requests

6 participants