From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#70724: 29.2.50; eglot-reconnect errors when the project is deleted Date: Thu, 02 May 2024 15:37:03 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13398"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmity@gutov.dev, app-emacs-dev@janestreet.com To: 70724@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 02 21:38:04 2024 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 1s2cFn-0003Ad-QW for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 02 May 2024 21:38:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2cFT-00036w-BS; Thu, 02 May 2024 15:37:43 -0400 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 1s2cFQ-00036V-D4 for bug-gnu-emacs@gnu.org; Thu, 02 May 2024 15:37:40 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2cFP-0002nT-NP for bug-gnu-emacs@gnu.org; Thu, 02 May 2024 15:37:40 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s2cFl-0006kB-KH for bug-gnu-emacs@gnu.org; Thu, 02 May 2024 15:38:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 May 2024 19:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70724 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.171467866325913 (code B ref -1); Thu, 02 May 2024 19:38:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 May 2024 19:37:43 +0000 Original-Received: from localhost ([127.0.0.1]:45566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2cFS-0006jt-J7 for submit@debbugs.gnu.org; Thu, 02 May 2024 15:37:43 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:39044) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s2cFP-0006jn-SA for submit@debbugs.gnu.org; Thu, 02 May 2024 15:37:41 -0400 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 1s2cEx-00031a-Qo for bug-gnu-emacs@gnu.org; Thu, 02 May 2024 15:37:12 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2cEr-0002lP-2x for bug-gnu-emacs@gnu.org; Thu, 02 May 2024 15:37:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1714678623; bh=HsRotOPpaHWjrXzxXabxrWnURS6qeU7SqBW9Ncv/+r4=; h=From:To:Cc:Subject:Date; b=Z6Wp+E/kyH86Ai5tdudXbRqk1spKOqA3n7xPBf3h7HCG8MGEcWiJfDuqAgffpveJY QSuTogNzcA3uKkBeSC6+G8tqR185iQcJeS1NPK8u9vJ3uQYnUi6lWnjz1nqR/CzTmC iVrCGIrYVU+BMaZZpESkA4j/6MqwU8HwyZHVzC8b+86mlxf8KKhD4ksSQgVKTgEKBY sS2j52cuuJHMXHOtt7y7tdoaVz85/1VbLHHH+AjnQLqFshCMRwmnN6qhfSeuWXcfOm uROkRw3RVojcQAyXtZPcnf42w2cdTRaRlyRVz1gLWNonvFEGGV4HJjMZGyTnhb4pH0 uX+jbCCXFpPlA== Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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:284347 Archived-At: In some project /home/foo/proj, with pretty much any LSP server: 1. In /home/foo/proj, M-x eglot, starting some LSP server 2. Delete the directory /home/foo/proj 3. The LSP server will crash/exit 4. The process sentinel for the server will run, running eglot--on-shutdown which by default will call eglot-reconnect 5. eglot-reconnect extracts the saved project instance out of the server, which has a root directory which no longer exists, and calls eglot--connect with it 6. eglot--connect calls project-name on a nonexistent project instance, which may fail with an error depending on the project implementation (I have a custom project implementation, but I think this can happen with project-vc too) 7. This causes the process sentinel to error. I think the right fix is probably for eglot--on-shutdown (or maybe eglot-reconnect) to call (project-current nil (project-root pr)) to find the new project instance. If that returns nil, the project has disappeared, and eglot should just not try to reconnect. This also would make eglot behave better if the project layout changes (e.g. if there are nested projects). Alternatively, maybe eglot--on-shutdown shouldn't automatically reconnect in the first place? Maybe reconnection should happen automatically only when some specific buffer tries to interact with the LSP - then it can run project-current in the context of that specific buffer, and see there's no project, and fail. Plus, if the user kills all the buffers in the project (possibly with project-kill-buffers) before deleting it, this approach would entirely avoid the unnecessary eglot reconnection attempt. In GNU Emacs 29.2.50 (build 2, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-04-25 built on igm-qws-u22796a Repository revision: d07451c1f8053fa355d091351a614f232995ab8c Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.9 (Green Obsidian) Configured using: 'configure -C --with-x-toolkit=lucid --with-gif=ifavailable' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: ELisp/l Minor modes in effect: repeat-mode: t delete-selection-mode: t global-so-long-mode: t pixel-scroll-precision-mode: t jane-fe-minor-mode: t jane-fe-jenga-minor-mode: t editorconfig-mode: t dired-omit-mode: t which-function-mode: t global-git-commit-mode: t magit-auto-revert-mode: t shell-dirtrack-mode: t server-mode: t savehist-mode: t save-place-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tab-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t context-menu-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Features: (magit-patch make-mode doctor texinfo texinfo-loaddefs completion emacs-news-mode latexenc mode-local minibuf-eldef ...) Memory information: ((conses 16 4170589 532507) (symbols 48 67528 55) (strings 32 645610 32608) (string-bytes 1 31944500) (vectors 16 203742) (vector-slots 8 4053669 619438) (floats 8 1045 1428) (intervals 56 410065 1774) (buffers 976 767))