rokucommunity / rokucommunity/brighterscript

LSP uncaught exception on receiving MethodNotFound error response from client

Open
#1,619 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
208
Forks
68
Avg merge
8h 39m
Merged PRs (30d)
39

Description

I'm trying to use the LSP with the Kakoune editor, using its kak-lsp plugin. kak-lsp appears not to support the "workspace/workspaceFolders" method requested by the LSP, so kak-lsp sends back a "method not found" error (code -32601). The bsc LSP appears not to handle this error response appropriately:

node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^

[ResponseError: Method not found
    at handleResponse (/nix/store/38pg66nsynrsmzcqmr3fcl8kj6d6l7kz-brighterscript-1.0.0-alpha.50/lib/node_modules/brighterscript/node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc/lib/common/connection.js:565:48)
    at handleMessage (/nix/store/38pg66nsynrsmzcqmr3fcl8kj6d6l7kz-brighterscript-1.0.0-alpha.50/lib/node_modules/brighterscript/node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc/lib/common/connection.js:345:13)
    at processMessageQueue (/nix/store/38pg66nsynrsmzcqmr3fcl8kj6d6l7kz-brighterscript-1.0.0-alpha.50/lib/node_modules/brighterscript/node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc/lib/common/connection.js:362:17)
    at Immediate.<anonymous> (/nix/store/38pg66nsynrsmzcqmr3fcl8kj6d6l7kz-brighterscript-1.0.0-alpha.50/lib/node_modules/brighterscript/node_modules/vscode-languageserver-protocol/node_modules/vscode-jsonrpc/lib/common/connection.js:334:13)
    at process.processImmediate (node:internal/timers:485:21)] {
  code: -32601,
  data: undefined
}

Node.js v22.17.0

I've tried digging into the bsc code and the LSP protocol code, but I can't locate the point of failure. Looking at the protocol code in vscode-jsonprc, it appears that some response promise is not having the error/reject case properly handled.

For reference, the kak-lsp logs:

LSP: INFO Starting language server bsc as `bsc --lsp --stdio`
LSP: DEBG lsp_config:
LSP: DEBG Language server(s) bsc are still not initialized, parking request EditorRequest { meta: EditorMeta { session: SessionId("22482"), client: Some(ClientId("client0")), buffile: "/home/pascal/workspaces/bsc/testme.brs", language_id: "brs", filetype: "brs", version: 1, hook: false, sourcing: false, language_server: {}, semantic_tokens: SemanticTokenConfig { faces: [SemanticTokenFace { face: "documentation", token: "comment", modifiers: [SemanticTokenModifier("documentation")] }, SemanticTokenFace { face: "comment", token: "comment", modifiers: [] }, SemanticTokenFace { face: "function", token: "function", modifiers: [] }, SemanticTokenFace { face: "function", token: "method", modifiers: [] }, SemanticTokenFace { face: "keyword", token: "keyword", modifiers: [] }, SemanticTokenFace { face: "module", token: "namespace", modifiers: [] }, SemanticTokenFace { face: "operator", token: "operator", modifiers: [] }, SemanticTokenFace { face: "string", token: "string", modifiers: [] }, SemanticTokenFace { face: "type", token: "type", modifiers: [] }, SemanticTokenFace { face: "default+d", token: "variable", modifiers: [SemanticTokenModifier("readonly")] }, SemanticTokenFace { face: "default+d", token: "variable", modifiers: [SemanticTokenModifier("constant")] }, SemanticTokenFace { face: "variable", token: "variable", modifiers: [] }] }, server: None, word_regex: None, servers: [0], legacy_dynamic_config: "", legacy_server_initialization_options: [] }, response_fifo: None, method: "textDocument/hover", params: EditorParams(Any { .. }) }
LSP: ERRO language servers bsc are still not initialized, parking request textDocument/hover
LSP: DEBG To server bsc: {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"kakoune-lsp","version":"18.2.0"},"positionEncodings":["utf-8","utf-16"],"regularExpressions":{"engine":"Rust regex"}},"offsetEncoding":["utf-8","utf-16"],"textDocument":{"callHierarchy":{"dynamicRegistration":false},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.fixAll","source.organizeImports"]}},"dynamicRegistration":false,"isPreferredSupport":false,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":false},"colorProvider":{"dynamicRegistration":false},"completion":{"completionItem":{"commitCharactersSupport":false,"deprecatedSupport":false,"documentationFormat":["markdown","plaintext"],"preselectSupport":false,"resolveSupport":{"properties":["additionalTextEdits","detail","documentation"]},"snippetSupport":true},"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":{"dynamicRegistration":false,"linkSupport":false},"definition":{"dynamicRegistration":false,"linkSupport":false},"documentHighlight":{"dynamicRegistration":false},"documentLink":{"dynamicRegistration":false,"tooltipSupport":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]}},"formatting":{"dynamicRegistration":false},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":false},"implementation":{"dynamicRegistration":false,"linkSupport":false},"inlayHint":{"dynamicRegistration":false},"onTypeFormatting":{"dynamicRegistration":false},"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]}},"rangeFormatting":{"dynamicRegistration":false},"references":{"dynamicRegistration":false},"rename":{"dynamicRegistration":false,"prepareSupport":false},"selectionRange":{},"semanticTokens":{"dynamicRegistration":true,"formats":["relative"],"requests":{"full":true,"range":false},"serverCancelSupport":true,"tokenModifiers":[],"tokenTypes":[]},"signatureHelp":{"contextSupport":false,"dynamicRegistration":false,"signatureInformation":{"documentationFormat":["plaintext"],"parameterInformation":{"labelOffsetSupport":false}}},"synchronization":{"didSave":true,"dynamicRegistration":false,"willSave":false,"willSaveWaitUntil":false},"typeDefinition":{"dynamicRegistration":false,"linkSupport":false}},"window":{"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":false,"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]}},"workspaceEdit":{"changeAnnotationSupport":{},"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","delete","rename"]},"workspaceFolders":false}},"clientInfo":{"name":"kakoune-lsp","version":"18.2.0"},"processId":22561,"rootPath":"/home/pascal/workspaces/bsc","rootUri":"file:///home/pascal/workspaces/bsc","trace":"off","workspaceFolders":[{"name":"/home/pascal/workspaces/bsc","uri":"file:///home/pascal/workspaces/bsc"}]},"id":0}
LSP: DEBG From server bsc: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":1,"completionProvider":{"resolveProvider":false,"triggerCharacters":["."],"allCommitCharacters":[".","@"]},"documentSymbolProvider":true,"workspaceSymbolProvider":true,"semanticTokensProvider":{"legend":{"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"]},"full":true},"referencesProvider":true,"codeActionProvider":{"codeActionKinds":["refactor"]},"signatureHelpProvider":{"triggerCharacters":["(",","]},"definitionProvider":true,"hoverProvider":true,"executeCommandProvider":{"commands":["TranspileFile"]}}}}
LSP: DEBG To server bsc: {"jsonrpc":"2.0","method":"initialized","params":{}}
LSP: DEBG Failed to read file /home/pascal/workspaces/bsc/testme.brs to simulate textDocument/didOpen: No such file or directory (os error 2)
LSP: DEBG To server bsc: {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"brs","text":"","uri":"file:///home/pascal/workspaces/bsc/testme.brs","version":1}}}
LSP: DEBG To server bsc: {"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":0,"line":0},"textDocument":{"uri":"file:///home/pascal/workspaces/bsc/testme.brs"}},"id":1}
LSP: DEBG From server bsc: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"[11:19:57:950 PM][LOG  ] onInitialized"}}
LSP: DEBG To editor `22482`: evaluate-commands -verbatim -try-client 'client0' lsp-show-message-log bsc '[11:19:57:950 PM][LOG  ] onInitialized'
LSP: log from bsc: [11:19:57:950 PM][LOG  ] onInitialized
LSP: DEBG From server bsc: {"jsonrpc":"2.0","id":0,"method":"workspace/workspaceFolders"}
LSP: WARN Unsupported method: workspace/workspaceFolders
LSP: DEBG To server bsc: {"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found"},"id":0}
LSP: DEBG From server bsc: {"jsonrpc":"2.0","method":"busyStatus","params":{"status":"busy","timestamp":1770506397955,"index":0,"activeRuns":[{"scope":"","label":"getHover","startTime":1770506397955}]}}

I believe this is a server issue rather than a client issue, as the MethodNotFound error response is a valid one according to the protocol.

NixOS 25.11

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the bsc LSP session with kak-lsp and trace handling of the workspace/workspaceFolders response through the LSP protocol layer, including the vscode-jsonrpc connection handling shown in the stack trace. The fix is done when a MethodNotFound response from the client no longer causes an uncaught exception; add or update a regression test if the existing LSP test structure provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.