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

Omnisharp crashes all the time #2391

Open
Igorgro opened this issue Apr 25, 2022 · 5 comments
Open

Omnisharp crashes all the time #2391

Igorgro opened this issue Apr 25, 2022 · 5 comments

Comments

@Igorgro
Copy link

Igorgro commented Apr 25, 2022

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 (dotnet/vscode-csharp#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:

2022-04-26.12-43-42.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
Copy link

LePau commented May 13, 2022

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
Copy link

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

@SomeoneIsWorking
Copy link

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
Copy link

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

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

@julian-di
Copy link

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.

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

6 participants