Skip to content

Conversation

@sonnyp
Copy link
Contributor

@sonnyp sonnyp commented Dec 26, 2023

Fixes #855

Copy link
Contributor

@janvhs janvhs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From reading the source, stopping the LSP on error cases, seems to resolve the case where the GC is overwhelmed. I think it is a way better solution compared to what I proposed in #855 ! :)

There is however an error in the type signature, which prevents me from fully trying it.

await Promise.all([
this.stdin.close_async(null),
this.stdout.close_async(null),
this.stdin.close_async(null).catch(console.error),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk what argument is missing, but here is a link to the docs: https://gjs-docs.gjsify.org/classes/Gio_2_0.Gio.OutputStreamClass.html#close_async

(re.sonny.Workbench.Devel:5): re.sonny.Workbench.Devel-CRITICAL **: 14:15:28.821: TypeError: method Gio.OutputStream.close_async: At least 3 arguments required, but only 2 passed
_promisify/proto[asyncFunc]/<@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:450:35
_promisify/proto[asyncFunc]@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:448:16
stop@resource:///re/sonny/Workbench/lsp/LSPClient.js:88:18
_read@resource:///re/sonny/Workbench/lsp/LSPClient.js:220:19
async*_start_process@resource:///re/sonny/Workbench/lsp/LSPClient.js:164:10
start@resource:///re/sonny/Workbench/lsp/LSPClient.js:49:10
setup@resource:///re/sonny/Workbench/langs/javascript/javascript.js:13:8
JavaScriptDocument@resource:///re/sonny/Workbench/langs/javascript/JavaScriptDocument.js:10:17
Window@resource:///re/sonny/Workbench/window.js:81:31
openDemo@resource:///re/sonny/Workbench/Library/Library.js:105:26
Library/</<@resource:///re/sonny/Workbench/Library/Library.js:42:15
EntryRow/<@resource:///re/sonny/Workbench/Library/EntryRow.js:25:12
_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and fixed

try {
return JSON.parse(str);
} catch (err) {
await this.stop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stopping the LSP on an error is a good idea, but not re-throwing the error could potentially make debugging harder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Knowing that the input isn't valid JSON isn't particularly helpful, so one has to investigate anyway.
Working with LSP servers is rather cumbersome 😞

@sonnyp sonnyp force-pushed the lsp-quit-on-unexpected branch from 356e08c to a9b16d2 Compare December 28, 2023 18:13
@sonnyp sonnyp merged commit 9592d0d into main Dec 28, 2023
@sonnyp sonnyp deleted the lsp-quit-on-unexpected branch December 28, 2023 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants