* bug#59146: Patch: improve eglot-shutdown-all
@ 2022-11-09 11:27 Evgeni Kolev
2022-11-10 17:20 ` João Távora
0 siblings, 1 reply; 2+ messages in thread
From: Evgeni Kolev @ 2022-11-09 11:27 UTC (permalink / raw)
To: 59146; +Cc: joaotavora
eglot-shutdown-all has a bug that results in partially stopping
servers - when a server shutdown timeouts (1.5s), an error is
propagated and eglot-shutdown-all does not try to shutdown the rest of
the servers.
The patch below (produced with "git show" to include a commit message)
modifies eglot-shutdown-all to ignore errors, converting them to
messages via "with-demoted-errors".
Comparison of old VS new behaviour follows.
Steps to reproduce:
1. start 2 different language servers, the servers should be slow to
stop (I use gopls in a monorepo, so slow startup time is guaranteed)
2. (optional) if your language server is not slow to stop, change the
timeout in eglot-shutdown from 1.5 sec to 0.1 sec to force a timeout
3. run eglot-shutdown-all
Before: only one of the 2 servers is stopped - 1st one times out, 2nd
one is not asked to stop at all. Messages:
```
[eglot] Asking EGLOT (project1/go-mode) politely to terminate
[jsonrpc] Server exited with status 9
down-list: jsonrpc-error: "request id=4 failed:",
(jsonrpc-error-message . "Timed out")
```
After: both servers are stopped, the timeout errors are converted to
messages by with-demoted-errors. Messages:
```
[eglot] Asking EGLOT (project1/go-mode) politely to terminate
[jsonrpc] Server exited with status 9
[eglot] shutdown all: (jsonrpc-error request id=2 failed:
(jsonrpc-error-message . Timed out))
[eglot] Asking EGLOT (project2/go-mode) politely to terminate
[jsonrpc] Server exited with status 9
[eglot] shutdown all: (jsonrpc-error request id=2 failed:
(jsonrpc-error-message . Timed out))
```
Patch:
Author: Evgeni Kolev <evgenysw@gmail.com>
Date: Wed Nov 9 13:17:01 2022 +0200
Ignore errors when shutting down all LSP servers
eglot-shutdown-all has a bug that results in partially stopping
servers: when a server shutdown timeouts (1.5s), an error is
propagated and eglot-shutdown-all does not try to shutdown the rest of
the servers.
* eglot.el (eglot-shutdown-all): Ignore errors when shutting down
servers, converting errors to messages.
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index ce989b5611..5a28c64bb0 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -877,7 +877,8 @@ eglot-shutdown-all
PRESERVE-BUFFERS as in `eglot-shutdown', which see."
(interactive (list current-prefix-arg))
(cl-loop for ss being the hash-values of eglot--servers-by-project
- do (cl-loop for s in ss do (eglot-shutdown s nil nil
preserve-buffers))))
+ do (with-demoted-errors "[eglot] shutdown all: %s"
+ (cl-loop for s in ss do (eglot-shutdown s nil nil
preserve-buffers)))))
(defun eglot--on-shutdown (server)
"Called by jsonrpc.el when SERVER is already dead."
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#59146: Patch: improve eglot-shutdown-all
2022-11-09 11:27 bug#59146: Patch: improve eglot-shutdown-all Evgeni Kolev
@ 2022-11-10 17:20 ` João Távora
0 siblings, 0 replies; 2+ messages in thread
From: João Távora @ 2022-11-10 17:20 UTC (permalink / raw)
To: Evgeni Kolev; +Cc: bug-gnu-emacs, 59146-done
Thanks, I applied the patch
João
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-10 17:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-09 11:27 bug#59146: Patch: improve eglot-shutdown-all Evgeni Kolev
2022-11-10 17:20 ` João Távora
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).