OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.79k stars 420 forks source link

Omnisharp crashes all the time #2391

Open Igorgro opened 2 years ago

Igorgro commented 2 years ago

I'm using omnisharp vscode extension and the omnisharp server crashes every 5-10 seconds with one the following errors:

[fail]: OmniSharp.Stdio.Host
        ************  Response (0.7755ms) ************ 
{
  "Request_seq": 23495,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')\\n   at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)\\n   at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset(SourceText text, Int32 lineNumber, Int32 offset) in /Users/runner/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 28\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetTextSpan(ICodeActionRequest request, SourceText sourceText) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 117\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 94\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 40\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 218\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 234\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 143\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /Users/runner/work/1/s/src/OmniSharp.Stdio/Host.cs:line 258\"",
  "Body": null,
  "Seq": 216652,
  "Type": "response"
}

or

[fail]: OmniSharp.Stdio.Host
        ************  Response (2.4202ms) ************ 
{
  "Request_seq": 413,
  "Command": "/quickinfo",
  "Running": true,
  "Success": false,
  "Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')\\n   at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)\\n   at Microsoft.CodeAnalysis.Text.TextLineCollection.GetPosition(LinePosition position)\\n   at OmniSharp.Extensions.SourceTextExtensions.GetTextPosition(SourceText sourceText, Request request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn/Extensions/SourceTextExtensions.cs:line 11\\n   at OmniSharp.Roslyn.CSharp.Services.QuickInfoProvider.Handle(QuickInfoRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/QuickInfoProvider.cs:line 61\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 218\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 234\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 143\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /Users/runner/work/1/s/src/OmniSharp.Stdio/Host.cs:line 258\"",
  "Body": null,
  "Seq": 25611,
  "Type": "response"
}

If I enable inlay hints, one more similar error appears:

[fail]: OmniSharp.Stdio.Host
        ************  Response (0.5080ms) ************ 
{
  "Request_seq": 411,
  "Command": "/inlayHint",
  "Running": true,
  "Success": false,
  "Message": "\"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter 'index')\\n   at Microsoft.CodeAnalysis.Text.SourceText.LineInfo.get_Item(Int32 index)\\n   at OmniSharp.Extensions.TextExtensions.GetPositionFromLineAndOffset(SourceText text, Int32 lineNumber, Int32 offset) in /Users/runner/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 28\\n   at OmniSharp.Extensions.TextExtensions.GetSpanFromRange(SourceText text, Range range) in /Users/runner/work/1/s/src/OmniSharp.Roslyn/Extensions/TextExtensions.cs:line 55\\n   at OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService.Handle(InlayHintRequest request) in /Users/runner/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/InlayHints/InlayHintService.cs:line 56\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 218\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 234\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /Users/runner/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 143\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /Users/runner/work/1/s/src/OmniSharp.Stdio/Host.cs:line 258\"",
  "Body": null,
  "Seq": 25602,
  "Type": "response"
}

I cannot find the correlation between the source code I'm typing and these error and I'm not sure, is it a problem of vscode extension or omnisharp itself. I already had the similar issue before (https://github.com/OmniSharp/omnisharp-vscode/issues/5149), but now i've disabled inlay hins at all but still have tons of errors.

Technical details: Vscode 1.66.2 OmniSharp version: 1.38.2-net6.0 OS: Arch Linux

UPD. A small reproduce:

https://user-images.githubusercontent.com/22894169/165274347-8d829436-b44d-4ff5-88d7-50a97f1a48ba.mp4

It is just simple webapi project, where I'm editing a dto. When the file is saved, the problem is gone then it returns after some time.

LePau commented 2 years ago

I had this same problem.

In my case, OmniSharp was confused about which project in my folder structure to load. I had to Ctrl+Shift+P and pick OmniSharp: Select Project, and it allowed me to select my project (solution actually), and then these exceptions went away and I was able to see my hints again.

Your folder structure is obviously different, and I only see one project in your video, but I wonder if selecting your project manually via the actions I just mentioned might help.

Helius01 commented 2 years ago

You maybe shocked but uninstalling Todo Tree solved it for me. i had this issue since 1 year ago .

SomeoneIsWorking commented 2 years ago

I get this in Razor. With and without useModernNet

You maybe shocked but uninstalling Todo Tree solved it for me.

Didn't solve it for me. Basically nothing is recognized. Happens only when there are multiple workspace folders and Razor project is not in the first workspace folder.

StaticBR commented 1 year ago

You maybe shocked but uninstalling Todo Tree solved it for me.

Did also solve my Problem. @Helius01 Thanks for sharing!

julian-di commented 4 months ago

I need omnisharp for a c# script, which is not supported in the new language server as far as i can see, but i also experience crashes all the times as the others here, i have a plain vscode without any plugins.