From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Evgeni Kolev Newsgroups: gmane.emacs.bugs Subject: bug#59146: Patch: improve eglot-shutdown-all Date: Wed, 9 Nov 2022 13:27:49 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25951"; mail-complaints-to="usenet@ciao.gmane.io" Cc: joaotavora@gmail.com To: 59146@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 09 12:29:18 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osjGf-0006cr-VW for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Nov 2022 12:29:18 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osjGR-0005Lm-JJ; Wed, 09 Nov 2022 06:29:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osjGQ-0005Ld-HF for bug-gnu-emacs@gnu.org; Wed, 09 Nov 2022 06:29:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osjGQ-0004U7-6J for bug-gnu-emacs@gnu.org; Wed, 09 Nov 2022 06:29:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1osjGP-00042r-Sj for bug-gnu-emacs@gnu.org; Wed, 09 Nov 2022 06:29:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Evgeni Kolev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Nov 2022 11:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 59146 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.166799330515503 (code B ref -1); Wed, 09 Nov 2022 11:29:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Nov 2022 11:28:25 +0000 Original-Received: from localhost ([127.0.0.1]:39164 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osjFp-00041z-FB for submit@debbugs.gnu.org; Wed, 09 Nov 2022 06:28:25 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:56630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1osjFn-00041r-5Z for submit@debbugs.gnu.org; Wed, 09 Nov 2022 06:28:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osjFl-00059K-RY for bug-gnu-emacs@gnu.org; Wed, 09 Nov 2022 06:28:21 -0500 Original-Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1osjFh-0004Lx-03 for bug-gnu-emacs@gnu.org; Wed, 09 Nov 2022 06:28:21 -0500 Original-Received: by mail-yb1-xb33.google.com with SMTP id j2so20640843ybb.6 for ; Wed, 09 Nov 2022 03:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=l+X3WkFvLg+qQs+bM9Q3AVPpaTmNjU6B6+smZdZV5rE=; b=p0EbIm66vD+oBNVIu2oyoUtTGy2slJbXs4tM1gXdmXm8+BFrRZ4d+PFPpNDXQ16dTJ qBaGnEmxsUE149Pu+VQ7ofhvRhlt2zIO1ILipEIht349zuNPY7U+MM2s5+dO07MW+fKp mzexJ85Y5tbEDb4AI84xaS6iWN3Qw09vau5LAzYrPRGm7onokw4+JfmyImv5qZoJAapR wEzamJUqB7wvea0MkrukB8Illo2FghuyfAh1W5C5epUV0CqEEXlTJ/C21SD3CSvGiw9p LjurDRWXQtkHBtzjhh5fKTcO1TtYOpOKsjN+QOUK334cXMm96dwOln0+AfSn1YdkXwJ+ 3l0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=l+X3WkFvLg+qQs+bM9Q3AVPpaTmNjU6B6+smZdZV5rE=; b=nJ2xHVWKJyyOPUOy/bAC6aCsUQDe42Ez48uALJfKTOZwUyJdiya1nSJiMuNA6IEE3P 7p7eaGL4CETtfz20vegPKkY47G/9qP7i7amb08QS1QlcOwhXigcolB4oCEJSDKZQm5Rt gbY0+HZAR0CfgWpHoQk+7hAp1UnWMfCVEnxBcGHj46Pv7LomvFADpNXDO7Kblwq+nBXH G+BVNIkUb31yRcvL/iMpAS2iAwnDHI4jEDgXzRAT86Xz10fzpb8sKCyE48uft5/+TGOh GVf8vKnrjOozIpoxNCHyPeA+HIcxqSsFwvqeREfm525VGMaIJy/pRO2Umq2fhL8txMMy CaIQ== X-Gm-Message-State: ACrzQf2Sv2D8yul+Uf4RuFXDngTGv6gccm16oRQAePCJ5yWqT0MxwL0G jrs3Mp5Fnr6+g9B7XUo43oQ+FgZ0A5jtOSvub3v1xsp7T6UhZ0P6 X-Google-Smtp-Source: AMsMyM4zRGfmlMV0dR/3SROhk9r17mJb24y49dKnTwoNtMbO47kOD3WTqlq3olCUdU3nCE5dVE229+Wz7BUtMpoWd5U= X-Received: by 2002:a5b:a0c:0:b0:6b4:446d:2f9 with SMTP id k12-20020a5b0a0c000000b006b4446d02f9mr61605119ybq.138.1667993295232; Wed, 09 Nov 2022 03:28:15 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::b33; envelope-from=evgenysw@gmail.com; helo=mail-yb1-xb33.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:247398 Archived-At: 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 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."