omnisharp-roslyn icon indicating copy to clipboard operation
omnisharp-roslyn copied to clipboard

Neovim LSP Error - Attempt to Index Local 'decoded' (a nil value)

Open MiliAxe opened this issue 2 years ago • 48 comments

Issue Description

I am encountering an error when using the OmniSharp Language Server Protocol (LSP) integration in Neovim. The error message I receive is as follows:

Error executing luv callback:
/usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:366: attempt to index local 'decoded' (a nil value)
stack traceback:
        /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:366: in function 'handle_body'
        /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:666: in function 'handle_body'
        /usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:240: in function </usr/local/share/nvim/runtime/lua/vim/lsp/rpc.lua:224>

Steps to Reproduce

  1. Open Neovim with the OmniSharp LSP integration.
  2. Open a C# project or file, and attempt to perform some LSP-related actions.
  3. Observe the error message mentioned above in the LSP log.

Expected Behavior

I expect the OmniSharp LSP integration to work without errors and to correctly handle symbol detection and LSP-related requests.

Actual Behavior

The error mentioned above is encountered but normal usage of language server is achievable if the error is ignored. it appears to be related to the decoding of JSON data within the LSP integration.

System Information

  • Neovim Version: NVIM v0.10.0-dev-1325+gc4f8be464 Build type: RelWithDebInfo LuaJIT 2.1.1696795921
  • OmniSharp Version: 1.39.10
  • Operating System: Arch Linux

Log Files

LspLog: [WARN][2023-10-11 02:21:40] ...lsp/handlers.lua:557 "OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = o#/projectdiagnosticstatus, Params = {\n \"Type\": \"background\",\n \"Status\": 0,\n \"ProjectFilePath\": \"(100%)\"\n}, TraceParent = , TraceState = } | @Request='OutgoingNotification { Method = o#/projectdiagnosticstatus, Params = {\n \"Type\": \"background\",\n \"Status\": 0,\n \"ProjectFilePath\": \"(100%)\"\n}, TraceParent = , TraceState = }'" [WARN][2023-10-11 02:21:40] ...lsp/handlers.lua:557 "OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = o#/projectconfiguration, Params = {\n \"ProjectId\": \"f86d6df5-e245-49aa-9e6a-140d54063466\",\n \"SessionId\": \"1909222218\",\n \"OutputKind\": 0,\n \"ProjectCapabilities\": [\n \"GenerateDocumentationFile\",\n \"CSharp\",\n \"Managed\",\n \"ReferencesFolder\",\n \"LanguageService\",\n \"RelativePathDerivedDefaultNamespace\",\n \"AssemblyReferences\",\n \"COMReferences\",\n \"ProjectReferences\",\n \"SharedProjectReferences\",\n \"OutputGroups\",\n \"AllTargetOutputGroups\",\n \"VisualStudioWellKnownOutputGroups\",\n \"SingleFileGenerators\",\n \"DeclaredSourceItems\",\n \"UserSourceItems\",\n \"CrossPlatformExecutable\",\n \"SupportsHotReload\",\n \"Pack\"\n ],\n \"TargetFrameworks\": [\n \"net7.0\"\n ],\n \"SdkVersion\": \"58988350\",\n \"References\": [\n \"f9b57385e04dcef1\",\n \"b04d1a92c03aa393\",\n \"740a41f35e38e687\",\n \"a650b002a55ee732\",\n \"8bb25cdfa9f58d95\",\n \"ca01f9c6c9519128\",\n \"a7db6d4c13eb109a\",\n \"4787ec450370cdc\",\n \"faae3cd2329a5f23\",\n \"b136c9057d0eac41\",\n \"a4be57a67913d9f2\",\n \"c2f7e51423366080\",\n \"9221249557edf7da\",\n \"ac08b9147e6c6cc1\",\n \"fc8f31a851b2f1e\",\n \"3d1fab7a1546aa70\",\n \"75c42701c310d265\",\n \"6eac5906d797823f\",\n \"51b6b65db45d8317\",\n \"977562ede61122d1\",\n \"6f06be6c7dad3d57\",\n \"782a823a2d8cd40\",\n \"13bbf2cbcdb96469\",\n \"a8b1d9f359d7b4f\",\n \"8db448e27f0bad1b\",\n \"5faa84ffcc646d16\",\n \"3dd9e1e713ce28c1\",\n \"bc70a3688f03b546\",\n \"3e025539204a5d59\",\n \"12bec27505c61c10\",\n \"65e9cc7358ddee2e\",\n \"7df5bfe00323a6a8\",\n \"ce3f444652eead51\",\n \"feebdde9a00fe94b\",\n \"22d24df113118e04\",\n \"6a8ada60e30e6abf\",\n \"6001a9b860f7e43\",\n \"e94e5ff7b2eb39a9\",\n \"46b5412910b12f1a\",\n \"eac4975c939bd705\",\n \"a777367473e5f95c\",\n \"f67433e0978efe89\",\n \"d574426ce261f3cd\",\n \"2620772be337bacb\",\n \"ce4b86769789bfd2\",\n \"afe098e2b8eb2364\",\n \"4bca77302b767821\",\n \"b42e3bf9c2caf9d\",\n \"11d6a5981dd09f1d\",\n \"2528657f041a0f71\",\n \"1a4910e7928d2be4\",\n \"385f6cb9a1a92341\",\n \"8a6a053fd546c4b9\",\n \"4bd5d70d9487a7\",\n \"546da94a433dd46b\",\n \"c8cd67501180cdb3\",\n \"99380cc3f9cb0f62\",\n \"2b71ac54faa4d900\",\n \"6d26f5b6d581bb7a\",\n \"e99748daf45287f7\",\n \"88a79e3fbc9be5a5\",\n \"baed534980001b3e\",\n \"a094f278ebd28638\",\n \"f02b6f1120327ed5\",\n \"1fdb3be137e7c8ab\",\n \"d8d06e6254ff9a8\",\n \"7a37191fa2429c0\",\n \"db2085d40be0c6b\",\n \"732e2f41e1ec328f\",\n \"cc0b8a0dc4b5cc17\",\n \"b3ec78066692ce40\",\n \"b633596fb5206911\",\n \"b1c086ddba588d7f\",\n \"3935c25fc587591d\",\n \"5db9cd2d6d302594\",\n \"1fe2caf02ff5116\",\n \"d1e401c8e175f133\",\n \"d795c4b069f42de2\",\n \"28889d355be716fb\",\n \"987004758afb653e\",\n \"a93a13f245d3dbf5\",\n \"c2c7e5dd6bcf2f46\",\n \"f40e391e11837c28\",\n \"1f1effdb4f95fef\",\n \"4b3556ed143bb1a1\",\n \"990c07b3a694f061\",\n \"16f3b3c6aa66dbea\",\n \"bbc2c7fb9307d0f8\",\n \"cae96c695fa0a849\",\n \"23af2e185bf7f884\",\n \"10682f5180926917\",\n \"531413e8ae8921e9\",\n \"cbb2e2956b8bc5a1\",\n \"693159958e045249\",\n \"abb76040f918f212\",\n \"2978ebe3fa017619\",\n \"d753dc831058d377\",\n \"5d5ab2fae13c7cd7\",\n \"6f36e9e201c8abbc\",\n \"2c2215284100c1bc\",\n \"abef39459b5f8089\",\n \"58b2ccb5d5268768\",\n \"f4c238ed95a4c9e0\",\n \"463559064b820a89\",\n \"f46a5248555641f3\",\n \"31a917d25f0111b0\",\n \"d9a0d90fcf36b125\",\n \"f707ec8ff0716b6a\",\n \"d31ae060adc0cf68\",\n \"b740561cbe999190\",\n \"6f6cd086b29443f\",\n \"3e2b84419c2678fe\",\n \"16aa5cd16608904e\",\n \"88efed4970ce8fb\",\n \"525af1cb4f8c1ef\",\n \"82365a1d92723ea2\",\n \"f9081118726c671d\",\n \"1dc6ba4b51a92fe2\",\n \"480fcc9a46d59829\",\n \"96ae799a9cd65a64\",\n \"1f0a5acc2009b69e\",\n \"53da3fcaf9d4a664\",\n \"762862983c40286f\",\n \"7143cd55e6267a10\",\n \"9c4f1e8060c475b4\",\n \"5641b1bfbef8f076\",\n \"c074fd9cba688aec\",\n \"6b8a7cd56172fed1\",\n \"5d25704a6a0be6ed\",\n \"7de0d61ed8a595ec\",\n \"85c2a8db5105888\",\n \"ec2dac2bf194d54a\",\n \"baae63d2bc6dd501\",\n \"6e18d5f5513ced07\",\n \"ecc917c3c9b5c475\",\n \"3e60a289d38463fa\",\n \"3297b865f846bd0a\",\n \"34cfcce7d574a410\",\n \"762c57508db7a1c2\",\n \"81016cf6be9235ed\",\n \"96f5a81e8df6f19c\",\n \"bc2ea691e56496f8\",\n \"5d957776a3bc8463\",\n \"4fcdd50549f35f69\",\n \"1613d6b76156e26a\",\n \"609f5396c0534146\",\n \"31be6951d8a1de6e\",\n \"d373f3c4566c70c6\",\n \"b42e1bda5a17dc0e\",\n \"3017ef0c38e2d837\",\n \"92e480fdaacc79e0\",\n \"ffb314483a45fa40\",\n \"3159cfd5553fa1b8\",\n \"6a5eaa177b0b8d54\",\n \"add48a46678bd09d\",\n \"c70f2a1b237f229d\",\n \"3beb376886d63c97\",\n \"363b07840a344182\",\n \"f638dfb632c7bb3e\",\n \"4fc1e02f10ba6dcc\",\n \"7f7e058ceeba44c4\",\n \"76fdeb10eb04a251\",\n \"c229c6a3986d545b\"\n ],\n \"FileExtensions\": [\n \"-1257278712\"\n ],\n \"FileCounts\": [\n 4\n ],\n \"SdkStyleProject\": true\n}, TraceParent = , TraceState = } | @Request='OutgoingNotification { Method = o#/projectconfiguration, Params = {\n \"ProjectId\": \"f86d6df5-e245-49aa-9e6a-140d54063466\",\n \"SessionId\": \"1909222218\",\n \"OutputKind\": 0,\n \"ProjectCapabilities\": [\n \"GenerateDocumentationFile\",\n \"CSharp\",\n \"Managed\",\n \"ReferencesFolder\",\n \"LanguageService\",\n \"RelativePathDerivedDefaultNamespace\",\n \"AssemblyReferences\",\n \"COMReferences\",\n \"ProjectReferences\",\n \"SharedProjectReferences\",\n \"OutputGroups\",\n \"AllTargetOutputGroups\",\n \"VisualStudioWellKnownOutputGroups\",\n \"SingleFileGenerators\",\n \"DeclaredSourceItems\",\n \"UserSourceItems\",\n \"CrossPlatformExecutable\",\n \"SupportsHotReload\",\n \"Pack\"\n ],\n \"TargetFrameworks\": [\n \"net7.0\"\n ],\n \"SdkVersion\": \"58988350\",\n \"References\": [\n \"f9b57385e04dcef1\",\n \"b04d1a92c03aa393\",\n \"740a41f35e38e687\",\n \"a650b002a55ee732\",\n \"8bb25cdfa9f58d95\",\n \"ca01f9c6c9519128\",\n \"a7db6d4c13eb109a\",\n \"4787ec450370cdc\",\n \"faae3cd2329a5f23\",\n \"b136c9057d0eac41\",\n \"a4be57a67913d9f2\",\n \"c2f7e51423366080\",\n \"9221249557edf7da\",\n \"ac08b9147e6c6cc1\",\n \"fc8f31a851b2f1e\",\n \"3d1fab7a1546aa70\",\n \"75c42701c310d265\",\n \"6eac5906d797823f\",\n \"51b6b65db45d8317\",\n \"977562ede61122d1\",\n \"6f06be6c7dad3d57\",\n \"782a823a2d8cd40\",\n \"13bbf2cbcdb96469\",\n \"a8b1d9f359d7b4f\",\n \"8db448e27f0bad1b\",\n \"5faa84ffcc646d16\",\n \"3dd9e1e713ce28c1\",\n \"bc70a3688f03b546\",\n \"3e025539204a5d59\",\n \"12bec27505c61c10\",\n \"65e9cc7358ddee2e\",\n \"7df5bfe00323a6a8\",\n \"ce3f444652eead51\",\n \"feebdde9a00fe94b\",\n \"22d24df113118e04\",\n \"6a8ada60e30e6abf\",\n \"6001a9b860f7e43\",\n \"e94e5ff7b2eb39a9\",\n \"46b5412910b12f1a\",\n \"eac4975c939bd705\",\n \"a777367473e5f95c\",\n \"f67433e0978efe89\",\n \"d574426ce261f3cd\",\n \"2620772be337bacb\",\n \"ce4b86769789bfd2\",\n \"afe098e2b8eb2364\",\n \"4bca77302b767821\",\n \"b42e3bf9c2caf9d\",\n \"11d6a5981dd09f1d\",\n \"2528657f041a0f71\",\n \"1a4910e7928d2be4\",\n \"385f6cb9a1a92341\",\n \"8a6a053fd546c4b9\",\n \"4bd5d70d9487a7\",\n \"546da94a433dd46b\",\n \"c8cd67501180cdb3\",\n \"99380cc3f9cb0f62\",\n \"2b71ac54faa4d900\",\n \"6d26f5b6d581bb7a\",\n \"e99748daf45287f7\",\n \"88a79e3fbc9be5a5\",\n \"baed534980001b3e\",\n \"a094f278ebd28638\",\n \"f02b6f1120327ed5\",\n \"1fdb3be137e7c8ab\",\n \"d8d06e6254ff9a8\",\n \"7a37191fa2429c0\",\n \"db2085d40be0c6b\",\n \"732e2f41e1ec328f\",\n \"cc0b8a0dc4b5cc17\",\n \"b3ec78066692ce40\",\n \"b633596fb5206911\",\n \"b1c086ddba588d7f\",\n \"3935c25fc587591d\",\n \"5db9cd2d6d302594\",\n \"1fe2caf02ff5116\",\n \"d1e401c8e175f133\",\n \"d795c4b069f42de2\",\n \"28889d355be716fb\",\n \"987004758afb653e\",\n \"a93a13f245d3dbf5\",\n \"c2c7e5dd6bcf2f46\",\n \"f40e391e11837c28\",\n \"1f1effdb4f95fef\",\n \"4b3556ed143bb1a1\",\n \"990c07b3a694f061\",\n \"16f3b3c6aa66dbea\",\n \"bbc2c7fb9307d0f8\",\n \"cae96c695fa0a849\",\n \"23af2e185bf7f884\",\n \"10682f5180926917\",\n \"531413e8ae8921e9\",\n \"cbb2e2956b8bc5a1\",\n \"693159958e045249\",\n \"abb76040f918f212\",\n \"2978ebe3fa017619\",\n \"d753dc831058d377\",\n \"5d5ab2fae13c7cd7\",\n \"6f36e9e201c8abbc\",\n \"2c2215284100c1bc\",\n \"abef39459b5f8089\",\n \"58b2ccb5d5268768\",\n \"f4c238ed95a4c9e0\",\n \"463559064b820a89\",\n \"f46a5248555641f3\",\n \"31a917d25f0111b0\",\n \"d9a0d90fcf36b125\",\n \"f707ec8ff0716b6a\",\n \"d31ae060adc0cf68\",\n \"b740561cbe999190\",\n \"6f6cd086b29443f\",\n \"3e2b84419c2678fe\",\n \"16aa5cd16608904e\",\n \"88efed4970ce8fb\",\n \"525af1cb4f8c1ef\",\n \"82365a1d92723ea2\",\n \"f9081118726c671d\",\n \"1dc6ba4b51a92fe2\",\n \"480fcc9a46d59829\",\n \"96ae799a9cd65a64\",\n \"1f0a5acc2009b69e\",\n \"53da3fcaf9d4a664\",\n \"762862983c40286f\",\n \"7143cd55e6267a10\",\n \"9c4f1e8060c475b4\",\n \"5641b1bfbef8f076\",\n \"c074fd9cba688aec\",\n \"6b8a7cd56172fed1\",\n \"5d25704a6a0be6ed\",\n \"7de0d61ed8a595ec\",\n \"85c2a8db5105888\",\n \"ec2dac2bf194d54a\",\n \"baae63d2bc6dd501\",\n \"6e18d5f5513ced07\",\n \"ecc917c3c9b5c475\",\n \"3e60a289d38463fa\",\n \"3297b865f846bd0a\",\n \"34cfcce7d574a410\",\n \"762c57508db7a1c2\",\n \"81016cf6be9235ed\",\n \"96f5a81e8df6f19c\",\n \"bc2ea691e56496f8\",\n \"5d957776a3bc8463\",\n \"4fcdd50549f35f69\",\n \"1613d6b76156e26a\",\n \"609f5396c0534146\",\n \"31be6951d8a1de6e\",\n \"d373f3c4566c70c6\",\n \"b42e1bda5a17dc0e\",\n \"3017ef0c38e2d837\",\n \"92e480fdaacc79e0\",\n \"ffb314483a45fa40\",\n \"3159cfd5553fa1b8\",\n \"6a5eaa177b0b8d54\",\n \"add48a46678bd09d\",\n \"c70f2a1b237f229d\",\n \"3beb376886d63c97\",\n \"363b07840a344182\",\n \"f638dfb632c7bb3e\",\n \"4fc1e02f10ba6dcc\",\n \"7f7e058ceeba44c4\",\n \"76fdeb10eb04a251\",\n \"c229c6a3986d545b\"\n ],\n \"FileExtensions\": [\n \"-1257278712\"\n ],\n \"FileCounts\": [\n 4\n ],\n \"SdkStyleProject\": true\n}, TraceParent = , TraceState = }'"

Thank you for your help in addressing this problem.

MiliAxe avatar Oct 10 '23 23:10 MiliAxe

Edit: Using an older version like 1.39.8 Does not give such an error.

Seems like this error started appearing from 1.39.9 onward.

In v1.39.9, this error keeps being spammed. unlike v1.39.10 that goes away if ignored

MiliAxe avatar Oct 11 '23 10:10 MiliAxe

Also having the exact same issue. Any updates? I am on v1.39.10 as well

kidkych avatar Oct 30 '23 02:10 kidkych

Edit: Using an older version like 1.39.8 Does not give such an error.

Seems like this error started appearing from 1.39.9 onward.

In 1.39.9 we took an updated build of the csharp-language-server-protocol libraries. It is likely a regression there. Has anyone been able to determine which request is causing the error? If so, we could open an issue at https://github.com/OmniSharp/csharp-language-server-protocol/issues

JoeRobich avatar Oct 31 '23 20:10 JoeRobich

Still has the same issue in 1.39.10

StreenJiang avatar Nov 23 '23 03:11 StreenJiang

Exact problem here. Except I only get it on a huge and old net3.1 project and, well, could be unrelated but the LSP spams errors, starting with the using statements:

The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)

Jonatanc05 avatar Nov 24 '23 20:11 Jonatanc05

Same issue in omnisharp 1.39.10 and neovim 0.9.4 on windows

leblocks avatar Nov 28 '23 12:11 leblocks

I too am having this problems from time to time.

I tried to do some debug printout in neovim and this is my finding (maybe someone here can make sense of them?)

in rpc.lua there is an method "create_read_loop" that has following while loop:

    while true do
      local headers, body = parse_chunk(chunk)
      if headers then
        if body == nil then
          print("BODY IS NIL IN create_read_loop");
        end
        if body == "null" then
          print("BODY is: \"null\", chunk: " .. dump(chunk));
        end
        handle_body(body)
        chunk = ''
      else
        break
      end
    end

As you can see I have added two if-cases for my debug print.

The second one is hit when this error is generated. I think the error could be cause by parse_chunk(chunk) returning the string "null" to body.

The chunk that caused "null" to be returned looked like this (note, I have redacted some part):

{
    "jsonrpc": "2.0",
    "method": "o#/projectchanged",
    "params": {
        "MsBuildProject": {
            "AssemblyName": "REDACTED",
            "Configuration": "Debug",
            "IntermediateOutputPath": "obj\\Debug\\net6.0\\",
            "IsExe": true,
            "IsUnityProject": false,
            "OutputPath": "bin\\Debug\\net6.0\\",
            "Path": "C:\\projects\\REDACTED\\tests\\REDACTED.csproj",
            "Platform": "AnyCPU",
            "ProjectGuid": "00000000-0000-0000-0000-000000000000",
            "SourceFiles": [
                " *** REDACTED *** "
            ],
            "TargetFramework": ".NETCoreApp,Version=v6.0",
            "TargetFrameworks": [
                {
                    "FriendlyName": ".NETCoreApp",
                    "Name": ".NETCoreApp",
                    "ShortName": "net6.0"
                }
            ],
            "TargetPath": "C:\\projects\\REDACTED\\tests\\REDACTED\\bin\\Debug\\net6.0\\REDACTED.dll"
        }
    }
}

teast avatar Dec 06 '23 06:12 teast

Same issue in omnisharp 1.39.11 and neovim 0.9.5 on Arch

KiLLeRRaT avatar Jan 09 '24 17:01 KiLLeRRaT

Same here.

sajadspeed avatar Jan 18 '24 10:01 sajadspeed

Having the same issue. System Information: OmniSharp v1.39.11, Neovim v0.9.5, Pop!_OS 22.04 LTS

omas313 avatar Jan 23 '24 05:01 omas313

Error executing vim.schedule lua callback: /opt/neovim/share/nvim/runtime/lua/vim/lsp/util.lua:1157: Cursor position outside buffer stack traceback: [C]: in function 'nvim_win_set_cursor' /opt/neovim/share/nvim/runtime/lua/vim/lsp/util.lua:1157: in function 'jump_to_location' /opt/neovim/share/nvim/runtime/lua/vim/lsp/handlers.lua:412: in function 'handler' /opt/neovim/share/nvim/runtime/lua/vim/lsp.lua:1393: in function '' vim/_editor.lua: in function <vim/_editor.lua:0> Press ENTER or type command to continue

◍ omnisharp
  OmniSharp language server based on Roslyn workspaces. This version of Omnisharp requires dotnet (.NET 6.0) to be
  installed.


  installed version v1.39.11                                      
  homepage          https://github.com/OmniSharp/omnisharp-roslyn 
  languages         C#                                            
  categories        LSP                                           
  executables       omnisharp                                     

  ↓ LSP server configuration schema (press enter to collapse)
    This is a read-only overview of the settings this server accepts. Note that some settings might not apply to neovim.

Same Problem, but i am fresh in omnisharp, perhaps bad config

Hannover1992 avatar Jan 23 '24 14:01 Hannover1992

Same issue.

OmniSharp: 1.39.11 EndevourOs: 2023.08.05

Kleppa avatar Jan 30 '24 10:01 Kleppa

Can confirm still happening on v1.39.11 but not v1.39.8 for me

NoodleBug avatar Jan 30 '24 21:01 NoodleBug

same issue occurs on v1.39.11 using Linux.

ram-xv avatar Feb 02 '24 21:02 ram-xv

Same issue occurs on v1.39.11 using MacOS, NeoVim 0.9.5.

jknopp avatar Feb 13 '24 23:02 jknopp

This issue seems related: https://github.com/OmniSharp/omnisharp-roslyn/issues/2594

616b2f avatar Feb 14 '24 23:02 616b2f

can confirm still an issue

superbrobenji avatar Feb 17 '24 20:02 superbrobenji

Still an issue on omnisharp 1.39.10, neovim 0.9.5 on Windows 11.

Rolling back to omnisharp 1.39.8 fixes the issue (if using Mason run :MasonInstall [email protected]).

Ani-Sako avatar Feb 18 '24 07:02 Ani-Sako

Still an issue on omnisharp 1.39.10, neovim 0.9.5 on Windows 11.

Rolling back to omnisharp 1.39.8 fixes the issue (if using Mason run :MasonInstall [email protected]).

You need an extra v in the version:

:MasonInstall [email protected]

sergiuser1 avatar Mar 04 '24 12:03 sergiuser1

same issue. omnisharp v1.39.11. NVIM v0.9.5. 6.6.9-arch1-1.

Green0wl avatar Mar 12 '24 11:03 Green0wl

The simplest workaround is to edit /usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:383 and add not decoded to the first check of handle_body()if not ok or not decoded then...

litoj avatar Apr 09 '24 12:04 litoj

Still an issue omnisharp v1.39.11. NVIM v0.9.5

VanAdcox avatar Apr 12 '24 01:04 VanAdcox

I have the same issue. I am also using Omnisharp v1.39.11 and Neovim v0.9.5 on Arch Linux.

mrphil2105 avatar Apr 22 '24 17:04 mrphil2105

Does anyone want to solve this problem? It seems that everyone has this problem.

sajadspeed avatar Apr 23 '24 04:04 sajadspeed

Does anyone want to solve this problem? It seems that everyone has this problem.

Yes of course I want, but for me, I don't really know neovim apis, I don't know lua, and I don't have much time to dig into it for now, so what I can do is to wait for a hero to save us hahahaha

StreenJiang avatar Apr 23 '24 04:04 StreenJiang

In my case going back to 1.39.8 didn't help, but going back to 1.38.2 did. This also fixed another issue I was having where code actions stopped working.

svermeulen avatar Apr 29 '24 08:04 svermeulen

In my case going back to 1.39.8 didn't help, but going back to 1.38.2 did. This also fixed another issue I was having where code actions stopped working.

I am having this issue in 1.39.9, 1.39.8, 1.38.2 only in large codebases. The error says "No code actions". I have temporarily switched to csharp-ls.

pluma9 avatar May 12 '24 05:05 pluma9

I too am having this problems from time to time.

I tried to do some debug printout in neovim and this is my finding (maybe someone here can make sense of them?)

in rpc.lua there is an method "create_read_loop" that has following while loop:

    while true do
      local headers, body = parse_chunk(chunk)
      if headers then
        if body == nil then
          print("BODY IS NIL IN create_read_loop");
        end
        if body == "null" then
          print("BODY is: \"null\", chunk: " .. dump(chunk));
        end
        handle_body(body)
        chunk = ''
      else
        break
      end
    end

As you can see I have added two if-cases for my debug print.

The second one is hit when this error is generated. I think the error could be cause by parse_chunk(chunk) returning the string "null" to body.

The chunk that caused "null" to be returned looked like this (note, I have redacted some part):

{
    "jsonrpc": "2.0",
    "method": "o#/projectchanged",
    "params": {
        "MsBuildProject": {
            "AssemblyName": "REDACTED",
            "Configuration": "Debug",
            "IntermediateOutputPath": "obj\\Debug\\net6.0\\",
            "IsExe": true,
            "IsUnityProject": false,
            "OutputPath": "bin\\Debug\\net6.0\\",
            "Path": "C:\\projects\\REDACTED\\tests\\REDACTED.csproj",
            "Platform": "AnyCPU",
            "ProjectGuid": "00000000-0000-0000-0000-000000000000",
            "SourceFiles": [
                " *** REDACTED *** "
            ],
            "TargetFramework": ".NETCoreApp,Version=v6.0",
            "TargetFrameworks": [
                {
                    "FriendlyName": ".NETCoreApp",
                    "Name": ".NETCoreApp",
                    "ShortName": "net6.0"
                }
            ],
            "TargetPath": "C:\\projects\\REDACTED\\tests\\REDACTED\\bin\\Debug\\net6.0\\REDACTED.dll"
        }
    }
}

I'm not able to reproduce this on the current nightly build of neovim. Here's the script I used

local body = 
[[
{
    "jsonrpc": "2.0",
    "method": "o#/projectchanged",
    "params": {
        "MsBuildProject": {
            "AssemblyName": "REDACTED",
            "Configuration": "Debug",
            "IntermediateOutputPath": "obj\\Debug\\net6.0\\",
            "IsExe": true,
            "IsUnityProject": false,
            "OutputPath": "bin\\Debug\\net6.0\\",
            "Path": "C:\\projects\\REDACTED\\tests\\REDACTED.csproj",
            "Platform": "AnyCPU",
            "ProjectGuid": "00000000-0000-0000-0000-000000000000",
            "SourceFiles": [
                " *** REDACTED *** "
            ],
            "TargetFramework": ".NETCoreApp,Version=v6.0",
            "TargetFrameworks": [
                {
                    "FriendlyName": ".NETCoreApp",
                    "Name": ".NETCoreApp",
                    "ShortName": "net6.0"
                }
            ],
            "TargetPath": "C:\\projects\\REDACTED\\tests\\REDACTED\\bin\\Debug\\net6.0\\REDACTED.dll"
        }
    }
}
]]

local ok, decoded = pcall(vim.json.decode, body, { luanil = { object = true } })

print(vim.inspect(decoded))

and that parses fine 🤔 but I still get this error when I open a project. I'll try to add some debugging code into my local neovim runtime and see what line is causing decoded = nil for me.

rudiejd avatar May 28 '24 22:05 rudiejd

This issue seems to have occurred after this commit. 51c5e00c57469d1f9ef7bcb7e5b5ca662355159b

nagaohiroki avatar Jun 25 '24 07:06 nagaohiroki

If I change 51c5e00c57469d1f9ef7bcb7e5b5ca662355159b back to b2e64c6006beed49460f063117793f42ab2a8a5c in CSharpDiagnosticWorkerWithAnalyzers.cs, nvim runs smoothly and the error goes away.

Changing from AnalyzerWorkQueue to AsyncAnalyzerWorkQueue seems to cause an error in nvim.

But even after changing ac7b9b8509356e39583de2b9fdf363005e6c8595(latest) CSharpDiagnosticWorkerWithAnalyzers.cs to b2e64c6006beed49460f063117793f42ab2a8a5c omnisharp-roslyn still doesn't work.

nagaohiroki avatar Jul 01 '24 11:07 nagaohiroki