elm-language-client-vscode icon indicating copy to clipboard operation
elm-language-client-vscode copied to clipboard

All requests fail with Cannot read property 'getTree' of undefined

Open pontaoski opened this issue 2 years ago • 6 comments

Expected Behavior

All requests don't fail

Current Behavior

All requests fail

Steps to Reproduce (for bugs)

  1. Open VSCode
  2. Open an Elm workspace
  3. Nothing works; output section shows all LSP requests are failing with 'getTree' of undefined

Context

This breaks all functionality for me; nothing works.

Your Environment

  • Version used: 2.4.1?
  • Editor name and version (e.g. VSCode 1.36.1): VSCode 1.65.0
  • Operating System and version: Fedora Rawhide

pontaoski avatar Mar 09 '22 23:03 pontaoski

[Info  - 18:26:53] Loading Elm tree-sitter syntax from ../../.vscode/extensions/elmtooling.elm-ls-vscode-2.4.1/server/out/tree-sitter-elm.wasm
[Info  - 18:26:54] Found 1 elm.json files for workspace /home/jblackquill/Dienste/HangManTasken
[Info  - 18:26:54] Found 1 unique elmWorkspaces for workspace /home/jblackquill/Dienste/HangManTasken
[Info  - 18:26:54] Starting language server for folder: file:///home/jblackquill/Dienste/HangManTasken
[Info  - 18:26:54] Elm version 0.19.1 detected.
[Info  - 18:26:54] Reading elm.json from /home/jblackquill/Dienste/HangManTasken/elm.json
[Warn  - 18:26:54] {"shortMessage":"Command failed with exit code 1: elm make","command":"elm make","escapedCommand":"elm make","exitCode":1,"stdout":"","stderr":"-- NO INPUT --------------------------------------------------------------------\n\nWhat should I make though? I need specific files like:\n\n    elm make src/Main.elm\n    elm make src/This.elm src/That.elm\n\nI recommend reading through https://guide.elm-lang.org for guidance on what to\nactually put in those files!\n\n","failed":true,"timedOut":false,"isCanceled":false,"killed":false}
[Error - 18:26:54] Error parsing files for /home/jblackquill/Dienste/HangManTasken/elm.json:
Error: ENOENT: no such file or directory, open '/home/jblackquill/.elm/0.19.1/packages/elm/http/2.0.0/elm.json'
[Error - 18:26:55] Notification handler 'textDocument/didOpen' failed with message: Cannot read property 'getTree' of undefined
[Error - 18:26:55] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: Cannot read property 'getTree' of undefined
  Code: -32603 
[Error - 18:26:55] Request textDocument/codeAction failed.
  Message: Request textDocument/codeAction failed with message: Cannot read property 'getTree' of undefined
  Code: -32603 
[Error - 18:26:55] Request textDocument/foldingRange failed.
  Message: Request textDocument/foldingRange failed with message: Cannot read property 'getTree' of undefined
  Code: -32603 
[Error - 18:26:55] TypeError: Cannot read property 'getTree' of undefined delayed processing of request

pontaoski avatar Mar 09 '22 23:03 pontaoski

Move/remove /home/jblackquill/.elm and try again, it should be recreated

razzeee avatar Mar 10 '22 00:03 razzeee

I got the same error message in the developer console, nothing worked. It worked a few days before. After removing ~/.elm, all VSCode files and doing a fresh install of VScode the error still popped up and nothing worked.

elm make does not sync dependencies for me.

Running elm init in a different folder worked and filled the package cache, which solved this problem completely and everything worked fine again.

I suggest upgrading the error handling in server/src/compiler/program.ts, as a failure to construct ElmPackageCache will leave this.forest undefined, resulting in this - not very useful - error message in the developer console.

The message in the debug log is not very informative as well, instead of console.error why not use window.showErrorMessage?

klassiker avatar Apr 19 '22 22:04 klassiker

Would you consider sending a patch for that?

For the console.error vs window.showErrorMessage, I do think that error messages that actively get pushed to the user should have a mostly defined text and not be an exception, that we display as a string.

razzeee avatar Apr 23 '22 11:04 razzeee

I would agree with you on that, but there is no indication that anything failed at all, causing even more irritation. Also, this is an IDE extension for software developers, not simple end users.

One could argue that developers should know about the output console, but for me this was a major obstacle, as I first had to figure out where VSCode provides this output. If it hadn't worked before, I would've assumed that I misconfigured something and wasted hours.

klassiker avatar Apr 23 '22 21:04 klassiker

This is still an ongoing issue, the extension does nothing besides basic syntax highlighting and crashes up to multiple times a second when editing Elm files

Here are my logs

[2022-06-17 14:32:44.074] [exthost] [error] Error: Request textDocument/codeLens failed with message: Cannot read properties of undefined (reading 'getTree')
	at handleResponse (/Users//.vscode/extensions/elmtooling.elm-ls-vscode-2.4.1/client/node_modules/vscode-jsonrpc/lib/common/connection.js:477:48)
	at processMessageQueue (/Users//.vscode/extensions/elmtooling.elm-ls-vscode-2.4.1/client/node_modules/vscode-jsonrpc/lib/common/connection.js:292:17)
	at Immediate.<anonymous> (/Users//.vscode/extensions/elmtooling.elm-ls-vscode-2.4.1/client/node_modules/vscode-jsonrpc/lib/common/connection.js:276:13)
	at processImmediate (node:internal/timers:464:21)

RocketRace avatar Jun 14 '22 06:06 RocketRace