elm-language-server icon indicating copy to clipboard operation
elm-language-server copied to clipboard

Error on elm-language-server attach due to node higher than 16

Open bwells opened this issue 2 years ago • 15 comments

Previously I had a working config for neovim and elm-language-server. I'm not sure if the problem is in elm-language-server, node, or the neovim side.

Expected Behavior

Previous integration worked fine.

Current Behavior

[START][2022-05-18 08:47:05] LSP logging initiated
[ERROR][2022-05-18 08:47:10] .../vim/lsp/rpc.lua:420	"rpc"	"elm-language-server"	"stderr"	"(node:79362) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time\n(Use `node --trace-warnings ...` to show where the warning was created)\n"
[ERROR][2022-05-18 08:47:10] ...lsp/handlers.lua:454	"Unhandled Rejection at: Promise [object Promise] reason:, TypeError: Failed to parse URL from /Users/kremlan/.local/share/nvim/lsp_servers/elmls/node_modules/@elm-tooling/elm-language-server/node_modules/web-tree-sitter/tree-sitter.wasm"

I can confirm that the referenced tree-sitter.wasm location exists at that location.

Possible Solution

It seems unlikely that elm-language-server itself changed causing the break based on the date of the last release, but I have no idea when I had previously updated my installation. I can't tell from the provided error message if this is a problem from within elmls, an incompatibility with a node upgrade, or an error occurring within neovim.

Steps to Reproduce (for bugs)

  1. Open any elm fine in neovim
  2. Introduce a syntax error
  3. Note that no LSP diagnostics are provided

Context

elm-language-server integration is now completely non-functional.

Your Environment

Neovim using lsp-config and lsp-installer. dotfiles available at https://github.com/bwells/dotfiles/tree/master/nvim

  • Version used: elm-language-server 2.2.1
  • Editor used: neovim 0.7
  • Environment name and version (e.g. node.js 5.4): Node v18.1.0
  • Operating System and version: macOS 12.4

bwells avatar May 18 '22 15:05 bwells

Did neovim or a plugin that's used for communicating with LSP change?

Did you check if /Users/kremlan/.local/share/nvim/lsp_servers/elmls/node_modules/@elm-tooling/elm-language-server/node_modules/web-tree-sitter/tree-sitter.wasm exists?

razzeee avatar May 18 '22 18:05 razzeee

Enough has changed over the months that trying to bisect for it between neovim versions, plugin versions, and node versions isn't really tractable. There's no plugin necessary for communicating with language servers necessary and fwiw other LSP servers continue to work with my setup.

Yes, the tree-sitter.wasm file exists.

Mostly I can't even tell what the error is telling me and which project I need to reach out to for help. Can you tell if this is neovim relaying an error back from elmls or if the error originates outside of elmls?

bwells avatar May 18 '22 18:05 bwells

Also, thanks!

bwells avatar May 18 '22 18:05 bwells

As it's a .lua error, it should be a neovim problem. Still, it seems to be with something in the server, but we only handle tree-sitter-elm.wasm directly and not tree-sitter.wasm

razzeee avatar May 18 '22 18:05 razzeee

FWIW "Unhandled Rejection at: Promise [object Promise] looks a lot more like JS/TS than Lua. My best guess is still something on the elmls side.

Can you provide any advice on how to more directly test elmls in a standalone mode?

bwells avatar May 18 '22 18:05 bwells

I've been able to track this down to a seeming incompatibility between elm-language-server and Node 18.x. Reverting node to 16.x has resolved the issue for me. Even more weirdly, the issue seems to resolve if I have both 18.x and 16.x installed locally with 18.x first in the path, but is reproducible if only 18.x is installed (via brew).

Presumably I'm not the only person using elmls with Node 18.x and this issue involves details more specific to my system. I'm happy to help with further debugging, but otherwise I'll just count the workaround as sufficient for now.

bwells avatar May 19 '22 10:05 bwells

I was having this issue in Linux with the Helix editor. I used nvm to switch from 18.x to 16.x and that fixed the problem for me as well.

bokubeam avatar Jun 01 '22 02:06 bokubeam

I've been able to track this down to a seeming incompatibility between elm-language-server and Node 18.x. Reverting node to 16.x has resolved the issue for me. Even more weirdly, the issue seems to resolve if I have both 18.x and 16.x installed locally with 18.x first in the path, but is reproducible if only 18.x is installed (via brew).

This fixed my problem :D

  • macos 12.3.1
  • Doom Emacs 28.1
  • I had installed node via brew, so to downgrade I had to do brew uninstall --ignore-dependencies node && brew install node@16 && brew link node@16

tillydray avatar Jun 02 '22 21:06 tillydray

Might be connected with https://github.com/tree-sitter/tree-sitter/issues/1765

razzeee avatar Jun 03 '22 07:06 razzeee

@razzeee, the log reported in the first post in this thread is the same as what I've observed when investigating my tree sitter issue, so yeah, it seems to be related to it

Krzysztof-Cieslak avatar Jun 06 '22 16:06 Krzysztof-Cieslak

I'm having what looks like the same exact issue and switching node from v18.4.0 back to node v16.14.2 seems to have done the trick.

matt-savvy avatar Jul 17 '22 21:07 matt-savvy

Same issue here. I tested using node 16.1.0, 16.16.0, and 18.6.0. Language server provided no feedback on either 16.16.0 or 18.6.0, but works great on 16.1.0. I used both helix editor and vim with ALE, so I wonder if that helps narrow down the problem?

brendantang avatar Jul 21 '22 14:07 brendantang

It needs to be fixed in upstream, nothing we can do in this repo for now.

razzeee avatar Jul 21 '22 16:07 razzeee

One thing is maybe put a warning in the READM E that this might not work versions of node greater than 16.x. I just spent the last several hours trying to get Vim + CoC to work with Elm. It was working, then I brew upgraded vim, and node, and some other things. I just observed of my developers having it on v17.5.0

jweir avatar Aug 18 '22 22:08 jweir

It needs to be fixed in upstream, nothing we can do in this repo for now.

~Is there an upstream report?~ Edit: nevermind

heyakyra avatar Sep 06 '22 02:09 heyakyra

  • Can not build from source with node 19
  • Package downloaded from npm doesn't start

starting

All works fine when building under node v16.

nomoredarts avatar Dec 02 '22 08:12 nomoredarts

I found a workaround in tree-sitter/tree-sitter:

Adding

try {
	
//@ts-ignore
	delete WebAssembly.instantiateStreaming
} catch {}

to the top of elm-language-server's index.js makes it work again.

VlkrS avatar Dec 10 '22 13:12 VlkrS

As far as I understood, it has been fixed in upstream, so we just need a release to happen on their side.

razzeee avatar Dec 10 '22 16:12 razzeee

Reference to potential fix, release pending:

https://github.com/tree-sitter/tree-sitter/pull/1913

andys8 avatar Jan 16 '23 12:01 andys8

I found a workaround in tree-sitter/tree-sitter:

Adding

	
//@ts-ignore
	delete WebAssembly.instantiateStreaming
} catch {}

to the top of elm-language-server's index.js makes it work again.

Worked for me as well (after correcting for typo of missing try). Link to original suggestion

nihil2501 avatar Jan 28 '23 07:01 nihil2501

I found a workaround in tree-sitter/tree-sitter: Adding

	
//@ts-ignore
	delete WebAssembly.instantiateStreaming
} catch {}

to the top of elm-language-server's index.js makes it work again.

Worked for me as well (after correcting for typo of missing try). Link to original suggestion

If I am using neovim + lazy, where should I add these few lines?

kumkee avatar Apr 25 '23 18:04 kumkee

@kumkee at the top of index.js in elm-languageserver

VlkrS avatar Apr 25 '23 18:04 VlkrS

Seems like a release was made three weeks ago now. https://github.com/tree-sitter/tree-sitter/releases/tag/v0.20.8

hovsater avatar Apr 27 '23 20:04 hovsater

See https://github.com/elm-tooling/elm-language-server/pull/954

razzeee avatar Apr 27 '23 21:04 razzeee

Can this be closed after the latest release?

jmbockhorst avatar May 05 '23 14:05 jmbockhorst

See #954

I can confirm the update work with node 20.1.0 So yes, you can close the issue.

kumkee avatar May 14 '23 03:05 kumkee