Skip to content

Dynamic registration attempted without capability check, crash when client returns "no handler" error for client/registerCapability #72

@csacca

Description

@csacca

Describe the bug

When connecting to clients that do not support dynamic registration for workspace/didChangeConfiguration, MATLAB-language-server attempts to dynamically register anyways and crashes if the client replies -32601 (no handler). This was observed with OpenCode v1.0.33.

Steps to reproduce

  1. Start matlab-language-server with a client (such as OpenCode v1.0.33) that:
    • does not advertise capabilities.workspace.didChangeConfiguration.dynamicRegistration: true
    • responds to client/registerCapability with -32601 (no handler)
  2. Complete initialize/initialized.
  3. Server unconditionally sends client/registerCapability for workspace/didChangeConfiguration.
  4. Client replies with "no handler" error; server crashes due to unhandled registration failure.

Expected behavior

  • Only attempt dynamic registration when dynamicRegistration set to true.
  • Treat registration errors as non-fatal and continue.

Environment

  • MATLAB-language-server Version: v1.3.6
  • MATLAB Version: R2025b Update 1 (25.2.0.3042426) 64-bit (glnxa64)
  • OS Version: Ubuntu 24.04.3 LTS as devcontainer (mcr.microsoft.com/devcontainers/base:ubuntu-24.04) with MATLAB feature (ghcr.io/mathworks/devcontainer-features/matlab)
  • Language Server Client: OpenCode v1.0.33.

Additional information

Example traffic between `opencode` and `matlab-langauge-server`

Example traffic between opencode and matlab-langauge-server

stdin:

Content-Length: 608

{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"rootUri":"file:///workspaces/agentic-matlab-example","processId":27266,"workspaceFolders":[{"name":"workspace","uri":"file:///workspaces/agentic-matlab-example"}],"initializationOptions":{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}},"capabilities":{"window":{"workDoneProgress":true},"workspace":{"configuration":true},"textDocument":{"synchronization":{"didOpen":true,"didChange":true},"publishDiagnostics":{"versionSupport":true}}}}}Content-Length: 52

{"jsonrpc":"2.0","method":"initialized","params":{}}Content-Length: 245

{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}}}Content-Length: 9598

{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///workspaces/agentic-matlab-example/pronav_intercept.m","languageId":"objective-c","version":0,"text":"%% pronav_intercept.m\n%\n% This script simulates and visualizes ..."}}}Content-Length: 103

{"jsonrpc":"2.0","id":0,"error":{"code":-32601,"message":"Unhandled method client/registerCapability"}}Content-Length: 197

{"jsonrpc":"2.0","id":1,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}Content-Length: 197

{"jsonrpc":"2.0","id":2,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}Content-Length: 197

{"jsonrpc":"2.0","id":3,"result":[{"MATLAB":{"installPath":"/opt/matlab/R2025b","indexWorkspace":false,"matlabConnectionTiming":"onStart","telemetry":false,"signIn":true,"prewarmGraphics":false}}]}

stdout:

Content-Length: 134

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"(02:41:58) matlabls: Log Directory: /tmp/matlabls_27270"}}Content-Length: 583

{"jsonrpc":"2.0","id":0,"result":{"capabilities":{"codeActionProvider":true,"completionProvider":{"triggerCharacters":[".","("," ",",","/","\\"]},"definitionProvider":true,"documentFormattingProvider":true,"documentRangeFormattingProvider":true,"executeCommandProvider":{"commands":["matlabls.lint.suppress.line","matlabls.lint.suppress.file"]},"foldingRangeProvider":true,"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"documentSymbolProvider":true,"renameProvider":{"prepareProvider":true},"documentHighlightProvider":true,"textDocumentSync":2}}}Content-Length: 201

{"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"aca83dcb-6596-4cd0-b267-0526a0f33060","method":"workspace/didChangeConfiguration","registerOptions":{}}]}}Content-Length: 101

{"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}Content-Length: 101

{"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}Content-Length: 125

{"jsonrpc":"2.0","method":"telemetry/logdata","params":{"eventKey":"ACTIONS","data":{"action_type":"openFile","result":"9"}}}Content-Length: 101

{"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}

stderr:

(node:27270) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565
                        responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
^

ResponseError: Unhandled method client/registerCapability
    at handleResponse (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:565:1)
    at handleMessage (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:345:1)
    at processMessageQueue (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:362:1)
    at Immediate.<anonymous> (webpack://matlab-language-server/node_modules/vscode-jsonrpc/lib/common/connection.js:334:1)
    at process.processImmediate (node:internal/timers:485:21) {
  code: -32601,
  data: undefined
}
Thrown at:
    at handleResponse (/opt/matlab-language-server/out/index.js:43412:48)
    at handleMessage (/opt/matlab-language-server/out/index.js:43192:13)
    at processMessageQueue (/opt/matlab-language-server/out/index.js:43209:17)
    at /opt/matlab-language-server/out/index.js:43181:13
    at processImmediate (node:internal/timers:485:21)


Node.js v22.21.1
Example `opencode.json` lsp config for `matlab-language-server`

Example opencode.json lsp config for matlab-language-server

{
  "$schema": "https://opencode.ai/config.json",
  "lsp": {
    "matlab": {
      "command": ["matlab-language-server", "--stdio"],
      "extensions": [".m"],
      "env":{
        "MLM_LICENSE_FILE": "{env:MLM_LICENSE_FILE}"
      },
      "initialization": {
        "MATLAB": {
          "installPath": "/opt/matlab/R2025b",
          "indexWorkspace": false,
          "matlabConnectionTiming": "onStart",
          "telemetry": false,
          "signIn": true,
          "prewarmGraphics": false
        }
      }
    }
  },
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions