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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 59146 in the body.
You can then email your comments to 59146 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59146; Package emacs. (Wed, 09 Nov 2022 11:29:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Evgeni Kolev <evgeni.d.kolev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 09 Nov 2022 11:29:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Cc: joaotavora <at> gmail.com
Subject: 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."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59146; Package emacs. (Thu, 10 Nov 2022 17:20:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: João Távora <joaotavora <at> gmail.com>
To: Evgeni Kolev <evgeni.d.kolev <at> gmail.com>
Cc: bug-gnu-emacs <at> gnu.org, 59146-done <at> debbugs.gnu.org
Subject: Re: Patch: improve eglot-shutdown-all
Date: Thu, 10 Nov 2022 17:20:21 +0000
Thanks,  I applied the patch

João





Reply sent to João Távora <joaotavora <at> gmail.com>:
You have taken responsibility. (Thu, 10 Nov 2022 17:20:02 GMT) Full text and rfc822 format available.

Notification sent to Evgeni Kolev <evgeni.d.kolev <at> gmail.com>:
bug acknowledged by developer. (Thu, 10 Nov 2022 17:20:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 09 Dec 2022 12:24:06 GMT) Full text and rfc822 format available.

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.