microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.18k stars 28.84k forks source link

TypeError: Failed to parse URL from /.vscode/extensions/rebornix.ruby-0.28.1/dist/server/tree-sitter.wasm #195159

Open SmileDMiao opened 12 months ago

SmileDMiao commented 12 months ago

before vscode update, everything was well, after update vsocde, then Open ruby project and ruby language server start failed.

abort(TypeError: Failed to parse URL from /Users/themadeknight/.vscode/extensions/rebornix.ruby-0.28.1/dist/server/tree-sitter.wasm). Build with -s ASSERTIONS=1 for more info.
(Use `Code Helper (Plugin) --trace-uncaught ...` to show where the exception was thrown)

Node.js v18.15.0
[Error - 21:21:26] Connection to server got closed. Server will not be restarted.
nirojsapkota commented 12 months ago

Getting the same issue since the update.

Herschdorfer commented 12 months ago

I have the same issue now:

TypeError: Failed to parse URL from /home/user/.vscode-server/extensions/rebornix.ruby-0.28.1/dist/server/tree-sitter.wasm

vscode 1.82.0 with latest https://marketplace.visualstudio.com/items?itemName=Shopify.ruby-lsp

guipace commented 12 months ago

+1 on this issue

dbaeumer commented 11 months ago

This has nothing to do with the gernal WASM support in VS Code. The ruby language server seems to load a tree-sitter wasm file.

tt4g commented 11 months ago

I have researched and posted on this issue (https://qiita.com/tt4q/items/0bffdcaf877d1ca1182a). However, since it is written in Japanese, many people will not be able to read it, so I will describe the main points.

Electron has been upgraded in Visual Studio Code v1.82, and Node.js has also been upgraded. The upgraded Node.js now provides a fetch API.

tree-sitter.wasm seems to be built with Emscripten. Emscripten is a tool to generate .wasm that supports multiple execution environments, and it seems to identify the execution environment by symbols defined at runtime.

Unfortunately, Emscripten had a runtime branch that said "if the fetch API is not defined, it is not Node.js". And, if it wasn't Node.js, Emscripten would have loaded the .wasm with the fetch API.

The fetch API specification requires support for the http:// and https:// schemes. Support for the file:// scheme is not required, and the Node.js fetch API does not support it for security reasons (nodejs/node#48554). However, Emscripten will attempt to load .wasm by fetch("/path/to/tree-sitter.wasm"). This is the cause of the TypeError: Failed to parse URL from /path/to/tree-sitter.wasm error.

Emscripten already fixed this bug (emscripten-core/emscripten#16913). It would be best to release rebornix.ruby extension that uses tree-sitter.wasm built by Emscripten after bug fixes. However, rebornix.ruby is no longer maintained.

The workaround I found is a --no-experimental-fetch option that prevents Node.js from defining a fetch API. Visual Studio Code does not have the ability to pass arguments to Node.js, so use the NODE_OPTIONS environment variable (e.g. NODE_OPTIONS="--no-experimental-fetch" code .). Note that this workaround will work, but may cause extensions that expect fetch provided by Node.js to stop working.

fmendez commented 3 weeks ago

In case is helpful to anyone else, the extension that's causing this is already deprecated: https://github.com/rubyide/vscode-ruby in favor of this other one: https://github.com/Shopify/vscode-shopify-ruby which doesn't have the issue described above.