1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:28:12 +00:00

HackStudio: Restart LanguageServer if it crashes

We now restart the language server transparently if it crashes.
If the language server crashes too frequently (current threshold is
twice within 3 seconds), we give up and will not attempt to restart it
again. HackStudio will still work fine, but features that depend on the
language server will not function.

To support this change we use a new class, 'ServerConnectionWrapper',
that holds the actual ServerConnection and is responsible for restarting
the language-server if it crashes.

Closes #5574.
This commit is contained in:
Itamar 2021-03-05 21:01:42 +02:00 committed by Andreas Kling
parent 4223f03b2b
commit cfa100cb65
3 changed files with 213 additions and 96 deletions

View file

@ -426,6 +426,11 @@ void Editor::set_document(GUI::TextDocument& doc)
if (m_language_client) {
set_autocomplete_provider(make<LanguageServerAidedAutocompleteProvider>(*m_language_client));
// NOTE:
// When a file is opened for the first time in HackStudio, its content is already synced with the filesystem.
// Otherwise, if the file has already been opened before in some Editor instance, it should exist in the LanguageServer's
// FileDB, and the LanguageServer should already have its up-to-date content.
// So it's OK to just pass an fd here (rather than the TextDocument's content).
int fd = open(code_document.file_path().characters(), O_RDONLY | O_NOCTTY);
if (fd < 0) {
perror("open");