question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

client/registerCapability sent for workspace/didChangeWorkspaceFolder even if dynamicRegistration set to false during initialization

See original GitHub issue

Moving from https://github.com/microsoft/pyright/issues/1302

Describe the bug

We have support for pyright as one of the language servers for neovim’s built in language client which uses vscode-languageserver-node. One issue seems to be cropping up on node 15 where failed callbacks result in node terminating the process. The main callback that is failing is client/registerCapability, (our client doesn’t support dynamic registration). When we report dynamicRegistration as false, pyright is still sending client/registerCapability requests

[ DEBUG ] 2020-12-20T13:55:08-0800 ] /home/michael/neovim/share/nvim/runtime/lua/vim/lsp/rpc.lua:489 ]	
"decoded"	{  id = 0,  jsonrpc = "2.0",  method = "client/registerCapability",  params = {    registrations = { {        
id = "807eedda-04cf-4637-9cb7-81d5f5d0e225",        method = "workspace/didChangeWorkspaceFolders",       
 registerOptions = vim.empty_dict()      } }  }}

We’re initializing the server with all dynamicRegistration capabilities registered as false

json of initialization params
{
  "initialize_params": {
    "capabilities": {
      "callHierarchy": {
        "dynamicRegistration": false,
        "textDocument": {
          "codeAction": {
            "codeActionLiteralSupport": {
              "codeActionKind": {
                "valueSet": [
                  "",
                  "Empty",
                  "QuickFix",
                  "Refactor",
                  "RefactorExtract",
                  "RefactorInline",
                  "RefactorRewrite",
                  "Source",
                  "SourceOrganizeImports",
                  "quickfix",
                  "refactor",
                  "refactor.extract",
                  "refactor.inline",
                  "refactor.rewrite",
                  "source",
                  "source.organizeImports"
                ]
              }
            },
            "dynamicRegistration": false
          },
          "completion": {
            "completionItem": {
              "commitCharactersSupport": false,
              "deprecatedSupport": false,
              "documentationFormat": [
                "markdown",
                "plaintext"
              ],
              "preselectSupport": false,
              "snippetSupport": false
            },
            "completionItemKind": {
              "valueSet": [
                1,
                2,
                3,
                4,
                5,
                6,
                7,
                8,
                9,
                10,
                11,
                12,
                13,
                14,
                15,
                16,
                17,
                18,
                19,
                20,
                21,
                22,
                23,
                24,
                25
              ],
              "contextSupport": false,
              "dynamicRegistration": false
            },
            "declaration": {
              "linkSupport": true
            },
            "definition": {
              "linkSupport": true
            },
            "documentHighlight": {
              "dynamicRegistration": false
            },
            "documentSymbol": {
              "dynamicRegistration": false,
              "hierarchicalDocumentSymbolSupport": true,
              "symbolKind": {
                "valueSet": [
                  1,
                  2,
                  3,
                  4,
                  5,
                  6,
                  7,
                  8,
                  9,
                  10,
                  11,
                  12,
                  13,
                  14,
                  15,
                  16,
                  17,
                  18,
                  19,
                  20,
                  21,
                  22,
                  23,
                  24,
                  25,
                  26
                ]
              }
            },
            "hover": {
              "contentFormat": [
                "markdown",
                "plaintext"
              ],
              "dynamicRegistration": false
            },
            "      implementation": {
              "        linkSupport": true
            },
            "references": {
              "dynamicRegistration": false
            },
            "rename": {
              "dynamicRegistration": false,
              "prepareSupport": true
            },
            "signatureHelp": {
              "dynamicRegistration": false,
              "signatureInformation": {
                "documentationFormat": [
                  "markdown",
                  "plaintext"
                ]
              }
            },
            "      synchronization": {
              "didSave": true,
              "dynamicRegistration": false,
              "willSave": false,
              "willSaveWaitUntil": false
            },
            "      typeDefinition": {
              "        linkSupport": true
            }
          },
          "workspace": {
            "applyEdit": true,
            "configuration": true,
            "symbol": {
              "dynamicRegistration": false,
              "hierarchicalWorkspaceSymbolSupport": true,
              "symbolKind": {
                "valueSet": [
                  1,
                  2,
                  3,
                  4,
                  5,
                  6,
                  7,
                  8,
                  9,
                  10,
                  11,
                  12,
                  13,
                  14,
                  15,
                  16,
                  17,
                  18,
                  19,
                  20,
                  21,
                  22,
                  23,
                  24,
                  25,
                  26
                ]
              }
            },
            "workspaceFolders": true
          }
        },
        "initializationOptions": {},
        "processId": 53558,
        "rootPath": "/home/michael/Repositories/pytorch_learning",
        "rootUri": "file:///home/michael/Repositories/pytorch_learning",
        "trace": "off",
        "workspaceFolders": [
          {
            "name": "/home/michael/Repositories/pytorch_learning",
            "uri": "file:///home/michael/Repositories/pytorch_learning"
          }
        ]
      }
    }
  }
}

To Reproduce This can’t be reproduced in vscode. I believe lsp-mode for emacs also implements dynamic registration, so the only way to reproduce this is to install neovim and nvim-lspconfig on node 14 (which doesn’t crash). I know this is out of scope for pyright so I will do all of the legwork on fixing this.

Expected behavior Pyright doesn’t send registerCapability requests to the client if dynamicRegistration is set to false (or unset)

VS Code extension or command-line Are you running pyright as a VS Code extension or a command-line tool? Which version? You can find the version of the VS Code extension by clicking on the Pyright icon in the extensions panel.

Additional context As mentioned I’m happy to submit a PR to fix this if acceptable, I’ve just had trouble finding exactly where in the pyright languageserver extension dynamicRegistration is read from initialization params, and where the registerCapability request is triggered.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
dbaeumercommented, Jan 5, 2021

Actually there is already a property on the server side to control this. It is changeNotifications defined here: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#workspace_workspaceFolders

I changed the code to honor that flag when accessing onDidChangeWorkspaceFolders. I will also clarify the spec around this.

0reactions
mjlbachcommented, Jan 5, 2021

Thank you! And also thank you for your work in supporting the broader language server protocol ecosystem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Aren't Boolean variables always false by default?
Yes, you should always initialize your variables. Until you intimately learn the times when it is and isn't necessary to do so explicitly,...
Read more >
Initializing a Boolean Array in Java | Baeldung
Therefore, if we want to initialize a boolean array with all false, we can simply create the array without setting the values.
Read more >
Solved: Boolean Array Initialization - NI Community
I already tried /Data Operations/Make current Value Default path after setting all elements in the array to "False". But still when I run ......
Read more >
How can we initialize a boolean array in Java? - Tutorialspoint
In some cases, we need to initialize all values of the boolean array with true or false. We can use the Arrays.fill() method...
Read more >
How to initialize a boolean array in JavaScript - GeeksforGeeks
A Boolean value can only be true or false and cannot have any other intermediate value. An array is a collection of data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found