unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Evgeni Kolev <evgeni.d.kolev@gmail.com>
To: 59146@debbugs.gnu.org
Cc: joaotavora@gmail.com
Subject: bug#59146: Patch: improve eglot-shutdown-all
Date: Wed, 9 Nov 2022 13:27:49 +0200	[thread overview]
Message-ID: <CAMCrgaWhn3VYGBzTFD4eFLhAMy+3wxGn97gMZgNiQy7tB6gNXg@mail.gmail.com> (raw)

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."





             reply	other threads:[~2022-11-09 11:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 11:27 Evgeni Kolev [this message]
2022-11-10 17:20 ` bug#59146: Patch: improve eglot-shutdown-all João Távora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMCrgaWhn3VYGBzTFD4eFLhAMy+3wxGn97gMZgNiQy7tB6gNXg@mail.gmail.com \
    --to=evgeni.d.kolev@gmail.com \
    --cc=59146@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).