GNU bug report logs - #59146
Patch: improve eglot-shutdown-all

Previous Next

Package: emacs;

Reported by: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>

Date: Wed, 9 Nov 2022 11:29:01 UTC

Severity: normal

Done: João Távora <joaotavora <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
To: 59146 <at> debbugs.gnu.org
Cc: joaotavora <at> gmail.com
Subject: bug#59146: Patch: improve eglot-shutdown-all
Date: Wed, 9 Nov 2022 13:27:49 +0200
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 <at> 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."




This bug report was last modified 2 years and 243 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.