interactive-data-language / vscode-idl

The Official IDL Extension for Visual Studio Code
https://interactive-data-language.github.io/vscode-idl/
MIT License
13 stars 16 forks source link

[Bug]: The connection to the IDL Language Server unexpectedly closed and will not be restarted #3

Closed bernatp3rs closed 1 year ago

bernatp3rs commented 1 year ago

Current Behavior

The following 2 errors happen very often:

It's quite annoying because without the server we cannot use the "Go to definition" shortcut and we have to restart the editor.

Expected Behavior

This is something that was not happening before

GitHub Repo

No response

Steps to Reproduce

  1. Don't know, the problem appears randomly

Failure Logs

No response

Operating System

IDL Version

8.5.1

Additional Information

No response

znorman-harris commented 1 year ago

Thanks for reporting! Do you have a lot of code on your path? This is typically reported when the language server runs out of memory which happens between 1-2 million lines of code. If you view machine resources, it will be hovering around 3-4 GB and then it will crash.

To help troubleshoot more, I'll need more information about the logs to see if anything is reported there. You can easily access them from here:

image

Additionally, there might be another "IDL" output channel with more information that can be found in the outputs section (Ctrl + ` to open up, then navigate to "OUTPUT"):

image

Without logs, it's going to be tricky to identify what is going on.

bernatp3rs commented 1 year ago

My library is indeed quite extensive, but I've never experienced any issues before. Please find below the content of the Extension Log. It appears that there is a memory issue. Any ideas on how to fix this?

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: 0x118d0a275 node::FatalException(v8::Isolate, v8::TryCatch const&) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 2: 0x118d0a394 node::OnFatalError(char const, char const) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 3: 0x113391b90 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, v8::OOMDetails const&) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 4: 0x113391b31 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate, char const, v8::OOMDetails const&) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 5: 0x11356b21e v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 6: 0x113542fb8 v8::internal::Factory::AllocateRaw(int, v8::internal::AllocationType, v8::internal::AllocationAlignment) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 7: 0x1121adccd v8::internal::FactoryBase::NewRawTwoByteString(int, v8::internal::AllocationType) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 8: 0x11397f481 v8::internal::String::SlowFlatten(v8::internal::Isolate, v8::internal::Handle, v8::internal::AllocationType) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 9: 0x113996c69 v8::internal::TransitionsAccessor::HasIntegrityLevelTransitionTo(v8::internal::Map, v8::internal::Symbol, v8::internal::PropertyAttributes) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 10: 0x11399620f v8::internal::TransitionsAccessor::HasIntegrityLevelTransitionTo(v8::internal::Map, v8::internal::Symbol, v8::internal::PropertyAttributes) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 11: 0x1133a2145 v8::ValueSerializer::WriteValue(v8::Local, v8::Local) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 12: 0x118d55fb9 node::OnFatalError(char const, char const) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 13: 0x118d5879c node::OnFatalError(char const, char const) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 14: 0x118d59288 node::OnFatalError(char const, char const) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 15: 0x113400e04 v8::internal::Accessors::MakeAccessor(v8::internal::Isolate, v8::internal::Handle, void ()(v8::Local, v8::PropertyCallbackInfo const&), void (*)(v8::Local, v8::Local, v8::PropertyCallbackInfo const&)) [/Applications/Visual Studio Code.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework] 16: 0x1221ff176f8 idl-client error The connection to the IDL Language Server unexpectedly closed [Error - 3:04:17 PM] Connection to server got closed. Server will not be restarted.

znorman-harris commented 1 year ago

Thanks for the extra detail!

There's a few ways that you can work around this. I'm working on getting a basic troubleshooting doc and a better error message in the UI to help point users to what they need to do. We will likely explore additional ways to help reduce memory usage as we move forward, but it might be a few weeks before we have anything official, depending on what else might come up.

In the meantime, here is the content of that document to help get you up and running. If you have questions, feel free to add them to this thread!


Language Server Crashes

This doc is a basic guide to walk through known issues with the language server and how you can work around them.

If you see errors such as " Connection to the language server got closed" or "The connection unexpectedly closed" means that there was a hard crash for the language server that requires a refresh of VSCode to start again.

At the time of writing this doc, the only known cause for this error is the server running out-of-memory.

Workarounds: Memory Reduction

There are two ways to work around the language server memory errors.

Using Node.js (recommended)

When the IDL extension starts, if it finds node.js on your path, it will automatically start the language server using node, which should remove this limitation. If you still see memory errors, then reach out to us on GitHub and let us know.

To install node.js, get the latest v18 release from https://nodejs.org/en/download/releases.

Once you install node.js, completely close and re-start VSCode (you may need to restart your computer so that it appears on your path).

Setting: Full Parse

We added an experimental feature which changes the way that we parse code on language server startup.

If you disable the "Language Server: Full Parse" setting then you should have much lower memory usage and faster startup times for large repositories or search paths.

However, it is experimental and you won't receive full diagnostics for a file until you start editing. But basic functionality such as go-to definition and hover help should work just fine.

bernatp3rs commented 1 year ago

I already have node.js installed on my computer (via brew):

brew list node /usr/local/Cellar/node/20.4.0/bin/node /usr/local/Cellar/node/20.4.0/etc/bash_completion.d/npm /usr/local/Cellar/node/20.4.0/include/node/ (63 files) /usr/local/Cellar/node/20.4.0/libexec/bin/ (2 files) /usr/local/Cellar/node/20.4.0/libexec/lib/ (2284 files) /usr/local/Cellar/node/20.4.0/share/doc/ (2 files) /usr/local/Cellar/node/20.4.0/share/man/man1/node.1

And I disabled the "Language Server: Full Parse" setting. However I keep having the same problems. Any other ideas?

znorman-harris commented 1 year ago

I'm not very familiar with brew, but what happens if you run "node --version" from a terminal window? It might be best if you try this from a terminal in VSCode to see if it is found.

One more question, how much RAM does your computer have?

Another indicator is, on startup, you'll see output at the top of the log that let's you know what we start the language server using. Here's what this looks like for me:

image

bernatp3rs commented 1 year ago

node --version v20.4.0

My computer has 16Gb of RAM

idl-client info Starting the language server using: VSCode

It seems that node is not being loaded on startup

I also tried, downgrading node to version 18 node --version v18.16.1

But still the same problems: idl-client info Starting the language server using: VSCode

znorman-harris commented 1 year ago

Actually, it looks like this might be a bug. I can reproduce on my Mac and I'm guessing there might be something odd about how we are trying to spawn node that work on Windows and not Mac (probably linux too).

Let me see if I can't figure out what's going on here.

znorman-harris commented 1 year ago

Edit: Forgot to add that I published a new version of the extension as 3.0.6 which is live.

Alright, it should be fixed and working now. I made a small change and was able to verify that Windows and Mac will pick things up correctly.

I'm going to close this, and if the fix doesn't work, let me know and I'll re-open!