Skip to content

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

Merged
rekram1-node merged 2 commits into
anomalyco:devfrom
csacca:fix/lsp-workspace-folders-handlers
Nov 8, 2025
Merged

rekram1-node merged 2 commits into
anomalyco:devfrom
csacca:fix/lsp-workspace-folders-handlers

Conversation

@csacca

@csacca csacca commented Nov 6, 2025

Copy link
Copy Markdown
Contributor

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

…ith MATLAB Language Server

- Add no-op handlers for client/registerCapability and client/unregisterCapability
- Implement workspace/workspaceFolders response aligned with initialize root
- Add tests using a fake LSP server to cover all three requests

Fixes anomalyco#4003
@rekram1-node

Copy link
Copy Markdown
Contributor

i think this one should be good to go can u fix the ci failure

Comment thread packages/opencode/src/lsp/client.ts Resolved
- Replace no-op handlers to return undefined per maintainer feedback
- Apply repository formatting (client and tests)
@rekram1-node
rekram1-node merged commit 271b679 into anomalyco:dev Nov 8, 2025
3 checks passed
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request Jun 14, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants