[PR #4007] fix(lsp): handle optional requests to avoid MethodNotFound (-32601) with MATLAB Language Server #10842

Closed
opened 2026-02-16 18:15:35 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4007

State: closed
Merged: Yes


Fix: Handle optional LSP requests to avoid MethodNotFound (-32601) crashing LSP server (matlab-language-server)

Fixes #4003

Summary

  • Add no-op handlers for client/registerCapability and client/unregisterCapability.
  • Implement workspace/workspaceFolders response aligned with the initialize root.
  • Eliminates MethodNotFound (-32601) noise and improves interoperability with matlab-language-server.

Motivation

Servers may issue optional LSP requests; unhandled methods cause MethodNotFound errors and crash matlab-language-server. Handling these requests is low-risk and LSP spec-aligned.

Changes

  • packages/opencode/src/lsp/client.ts
    • Register handlers before connection.listen():
      • connection.onRequest("client/registerCapability", async () => ({} as any))
      • connection.onRequest("client/unregisterCapability", async () => ({} as any))
      • connection.onRequest("workspace/workspaceFolders", async () => [{ name: "workspace", uri: "file://" + input.root }])

Tests

  • packages/opencode/test/lsp/client.test.ts
    • Covers all three requests using packages/opencode/test/fixture/lsp/fake-lsp-server.js.

Manual validation

  • Launch matlab-language-server via opencode.json (see #4003 for configuration details); open a .m file; verify no MethodNotFound (-32601) for the above methods; diagnostics flow; LSP server does not crash.
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4007 **State:** closed **Merged:** Yes --- # Fix: Handle optional LSP requests to avoid `MethodNotFound` (-32601) crashing LSP server (`matlab-language-server`) Fixes #4003 ## Summary - Add no-op handlers for `client/registerCapability` and `client/unregisterCapability`. - Implement `workspace/workspaceFolders` response aligned with the initialize root. - Eliminates `MethodNotFound` (-32601) noise and improves interoperability with `matlab-language-server`. ## Motivation Servers may issue optional LSP requests; unhandled methods cause `MethodNotFound` errors and crash `matlab-language-server`. Handling these requests is low-risk and LSP spec-aligned. ## Changes - packages/opencode/src/lsp/client.ts - Register handlers before `connection.listen()`: - `connection.onRequest("client/registerCapability", async () => ({} as any))` - `connection.onRequest("client/unregisterCapability", async () => ({} as any))` - `connection.onRequest("workspace/workspaceFolders", async () => [{ name: "workspace", uri: "file://" + input.root }])` ## Tests - packages/opencode/test/lsp/client.test.ts - Covers all three requests using `packages/opencode/test/fixture/lsp/fake-lsp-server.js`. ## Manual validation - Launch `matlab-language-server` via `opencode.json` (see #4003 for configuration details); open a `.m` file; verify no `MethodNotFound` (-32601) for the above methods; diagnostics flow; LSP server does not crash.
yindo added the pull-request label 2026-02-16 18:15:35 -05:00
yindo closed this issue 2026-02-16 18:15:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10842