[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa 581608f 115/139: Resist server failure during sync
From: |
João Távora |
Subject: |
[elpa] externals/elpa 581608f 115/139: Resist server failure during synchronous requests |
Date: |
Mon, 14 May 2018 09:53:47 -0400 (EDT) |
branch: externals/elpa
commit 581608fa8c3f319415a3476a949b53e209299bc8
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Resist server failure during synchronous requests
Calling the error handler unprotected could lead to the rest of the
sentinel not running at all. This defeated the auto-reconnection in
Rust, for example.
* eglot.el (eglot--process-sentinel): Rework.
---
eglot.el | 81 +++++++++++++++++++++++++++++++---------------------------------
1 file changed, 39 insertions(+), 42 deletions(-)
diff --git a/eglot.el b/eglot.el
index bf0b9e9..d49367b 100644
--- a/eglot.el
+++ b/eglot.el
@@ -339,50 +339,47 @@ INTERACTIVE is t if called interactively."
(defvar eglot--inhibit-auto-reconnect nil
"If non-nil, don't autoreconnect on unexpected quit.")
-(defun eglot--process-sentinel (process change)
- "Called with PROCESS undergoes CHANGE."
+(defun eglot--process-sentinel (proc change)
+ "Called when PROC undergoes CHANGE."
(eglot--debug "(sentinel) Process state changed to %s" change)
- (when (not (process-live-p process))
- ;; Cancel timers and error any outstanding continuations
- ;;
+ (when (not (process-live-p proc))
+ ;; Cancel outstanding timers
(maphash (lambda (_id triplet)
- (cl-destructuring-bind (_success error timeout) triplet
- (cancel-timer timeout)
- (funcall error :code -1 :message (format "Server died"))))
- (eglot--pending-continuations process))
- ;; Turn off `eglot--managed-mode' where appropriate.
- ;;
- (dolist (buffer (buffer-list))
- (with-current-buffer buffer
- (when (eglot--buffer-managed-p process)
- (eglot--managed-mode -1))))
- ;; Forget about the process-project relationship
- ;;
- (setf (gethash (eglot--project process) eglot--processes-by-project)
- (delq process
- (gethash (eglot--project process)
eglot--processes-by-project)))
- (cond ((eglot--moribund process)
- (eglot--message "(sentinel) Moribund process exited with status %s"
- (process-exit-status process)))
- ((null eglot--inhibit-auto-reconnect)
- (eglot--warn
- "(sentinel) Reconnecting after process unexpectedly changed to
`%s'."
- change)
- (condition-case-unless-debug err
- (eglot-reconnect process)
- (error (eglot--warn "Auto-reconnect failed: %s " err) ))
- (setq eglot--inhibit-auto-reconnect
- (run-with-timer
- 3 nil
- (lambda ()
- (setq eglot--inhibit-auto-reconnect nil)))))
- (t
- (eglot--warn
- "(sentinel) Not auto-reconnecting, last one didn't last long."
- change)))
- (force-mode-line-update t)
- (delete-process process)))
-
+ (cl-destructuring-bind (_success _error timeout) triplet
+ (cancel-timer timeout)))
+ (eglot--pending-continuations proc))
+ (unwind-protect
+ ;; Call all outstanding error handlers
+ (maphash (lambda (_id triplet)
+ (cl-destructuring-bind (_success error _timeout) triplet
+ (funcall error :code -1 :message (format "Server died"))))
+ (eglot--pending-continuations proc))
+ ;; Turn off `eglot--managed-mode' where appropriate.
+ (dolist (buffer (buffer-list))
+ (with-current-buffer buffer
+ (when (eglot--buffer-managed-p proc)
+ (eglot--managed-mode -1))))
+ ;; Forget about the process-project relationship
+ (setf (gethash (eglot--project proc) eglot--processes-by-project)
+ (delq proc
+ (gethash (eglot--project proc) eglot--processes-by-project)))
+ (cond ((eglot--moribund proc)
+ (eglot--message "(sentinel) Moribund process exited with status
%s"
+ (process-exit-status proc)))
+ ((null eglot--inhibit-auto-reconnect)
+ (eglot--warn
+ "(sentinel) Reconnecting after process unexpectedly changed to
`%s'."
+ change)
+ (setq eglot--inhibit-auto-reconnect
+ (run-with-timer 3 nil
+ (lambda ()
+ (setq eglot--inhibit-auto-reconnect
nil))))
+ (eglot-reconnect proc))
+ (t
+ (eglot--warn
+ "(sentinel) Not auto-reconnecting, last one didn't last long."
+ change)))
+ (delete-process proc))))
(defun eglot--process-filter (proc string)
"Called when new data STRING has arrived for PROC."
(when (buffer-live-p (process-buffer proc))
- [elpa] externals/elpa a7ddce6 080/139: Support javascript's javascript-typescript-langserver, (continued)
- [elpa] externals/elpa a7ddce6 080/139: Support javascript's javascript-typescript-langserver, João Távora, 2018/05/14
- [elpa] externals/elpa af14364 093/139: Only request stuff that server says it's capable of, João Távora, 2018/05/14
- [elpa] externals/elpa d33a9b5 103/139: Simplify eglot--signal-textDocument/didChange, João Távora, 2018/05/14
- [elpa] externals/elpa 56c2e1d 104/139: Get rid of eglot-mode, João Távora, 2018/05/14
- [elpa] externals/elpa bbc64b4 087/139: Clean up client capabilities, João Távora, 2018/05/14
- [elpa] externals/elpa 23b79e0 111/139: Shorten summary line to appease package-lint.el, João Távora, 2018/05/14
- [elpa] externals/elpa 24466a9 096/139: When killing server, always wait 3 seconds, João Távora, 2018/05/14
- [elpa] externals/elpa 3a6c637 099/139: Support textDocument/rename, João Távora, 2018/05/14
- [elpa] externals/elpa 458bc69 110/139: More correctly setup rust-mode-related autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 3dcbc30 109/139: Add minimal headers, commentary and autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 581608f 115/139: Resist server failure during synchronous requests,
João Távora <=
- [elpa] externals/elpa 41f5922 137/139: Now send willSaveWaitUntil, João Távora, 2018/05/14
- [elpa] externals/elpa 05c67ee 112/139: Adjust flymake integration, João Távora, 2018/05/14
- [elpa] externals/elpa f89f859 114/139: Simplify mode-line updating logic, João Távora, 2018/05/14
- [elpa] externals/elpa 0625b6c 123/139: (eglot--xref-make): Fix Use of cl-destructuring-bind., João Távora, 2018/05/14
- [elpa] externals/elpa 56cf02d 126/139: Rework autoreconnection logic, João Távora, 2018/05/14
- [elpa] externals/elpa 49fb02f 135/139: Use RLS in Travis CI and add actual tests, João Távora, 2018/05/14
- [elpa] externals/elpa 29f58a6 127/139: Get rid of catch/loop/throw idiom (suggested by Thien-Thi Nguyen), João Távora, 2018/05/14
- [elpa] externals/elpa 418412b 131/139: Fix copyright header. Obviously not since 2003, João Távora, 2018/05/14
- [elpa] externals/elpa 54fc885 113/139: More RLS-specifics: update Flymake diags when indexing done, João Távora, 2018/05/14
- [elpa] externals/elpa 8a80fb7 105/139: Simplify `eglot-shutdown`, João Távora, 2018/05/14