joaotavora / eglot

A client for Language Server Protocol servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Future proofing eglot-connect-timeout for newest emacs

BrunodaSilvaBelo opened this issue · comments

Hi, I use emacs' git version and with eglot 1.16 in this build GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.39, cairo version 1.18.0) of 2023-12-27 had a breaking change. I always set eglot-connect-timeout to nil, but now i'm receiving this error:

Debugger entered--Lisp error: (wrong-type-argument timerp nil)
  cancel-timer(nil)
  jsonrpc--remove(#<eglot-lsp-server eglot-lsp-server-156e2b0b5864> 1)
  jsonrpc-connection-receive(#<eglot-lsp-server eglot-lsp-server-156e2b0b5864> (:jsonrpc "2.0" :id 1 :result (:capabilities (:completionProvider (:triggerCharacters ["2" ":" "#" "\\"]) :documentFormattingProvider t :textDocumentSync (:change 2 :openClose t :save (:includeText :json-false) :willSave t :willSaveWaitUntil t)) :serverInfo (:name "beancount-language-server" :version "1.3.1")) :jsonrpc-json "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"capabilities\":{\"completionProvider\":{\"triggerCharacters\":[\"2\",\":\",\"#\",\"\\\\\"]},\"documentFormattingProvider\":true,\"textDocumentSync\":{\"change\":2,\"openClose\":true,\"save\":{\"includeText\":false},\"willSave\":true,\"willSaveWaitUntil\":true}},\"serverInfo\":{\"name\":\"beancount-language-server\",\"version\":\"1.3.1\"}}}"))
  #f(compiled-function (m) #<bytecode -0xa23201442836311>)((:jsonrpc "2.0" :id 1 :result (:capabilities (:completionProvider (:triggerCharacters ["2" ":" "#" "\\"]) :documentFormattingProvider t :textDocumentSync (:change 2 :openClose t :save (:includeText :json-false) :willSave t :willSaveWaitUntil t)) :serverInfo (:name "beancount-language-server" :version "1.3.1")) :jsonrpc-json "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"capabilities\":{\"completionProvider\":{\"triggerCharacters\":[\"2\",\":\",\"#\",\"\\\\\"]},\"documentFormattingProvider\":true,\"textDocumentSync\":{\"change\":2,\"openClose\":true,\"save\":{\"includeText\":false},\"willSave\":true,\"willSaveWaitUntil\":true}},\"serverInfo\":{\"name\":\"beancount-language-server\",\"version\":\"1.3.1\"}}}"))
  apply(#f(compiled-function (m) #<bytecode -0xa23201442836311>) (:jsonrpc "2.0" :id 1 :result (:capabilities (:completionProvider (:triggerCharacters ["2" ":" "#" "\\"]) :documentFormattingProvider t :textDocumentSync (:change 2 :openClose t :save (:includeText :json-false) :willSave t :willSaveWaitUntil t)) :serverInfo (:name "beancount-language-server" :version "1.3.1")) :jsonrpc-json "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"capabilities\":{\"completionProvider\":{\"triggerCharacters\":[\"2\",\":\",\"#\",\"\\\\\"]},\"documentFormattingProvider\":true,\"textDocumentSync\":{\"change\":2,\"openClose\":true,\"save\":{\"includeText\":false},\"willSave\":true,\"willSaveWaitUntil\":true}},\"serverInfo\":{\"name\":\"beancount-language-server\",\"version\":\"1.3.1\"}}}"))
  timer-event-handler([t 25996 58782 45355 nil #f(compiled-function (m) #<bytecode -0xa23201442836311>) ((:jsonrpc "2.0" :id 1 :result (:capabilities (:completionProvider (:triggerCharacters ["2" ":" "#" "\\"]) :documentFormattingProvider t :textDocumentSync (:change 2 :openClose t :save (:includeText :json-false) :willSave t :willSaveWaitUntil t)) :serverInfo (:name "beancount-language-server" :version "1.3.1")) :jsonrpc-json "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"capabilities\":{\"completionProvider\":{\"triggerCharacters\":[\"2\",\":\",\"#\",\"\\\\\"]},\"documentFormattingProvider\":true,\"textDocumentSync\":{\"change\":2,\"openClose\":true,\"save\":{\"includeText\":false},\"willSave\":true,\"willSaveWaitUntil\":true}},\"serverInfo\":{\"name\":\"beancount-language-server\",\"version\":\"1.3.1\"}}}")) nil 361000 nil])
  accept-process-output(nil 3)
  eglot--connect((beancount-mode) (transient . "/home/edge/.emacs.d/beancount/") eglot-lsp-server ("beancount-language-server" "--stdio") ("beancount"))
  eglot((beancount-mode) (transient . "/home/edge/.emacs.d/beancount/") eglot-lsp-server ("beancount-language-server" "--stdio") ("beancount") t)
  funcall-interactively(eglot (beancount-mode) (transient . "/home/edge/.emacs.d/beancount/") eglot-lsp-server ("beancount-language-server" "--stdio") ("beancount") t)
  hydra--call-interactively-remap-maybe(eglot)
  (progn (setq this-command 'eglot) (hydra--call-interactively-remap-maybe #'eglot))
  eglot/eglot-and-exit()
  funcall-interactively(eglot/eglot-and-exit)
  command-execute(eglot/eglot-and-exit)

Setting eglot-connect-timeout to integer solves this problem, maybe in the future, a new way to make eglot never timeout is needed.

@BrunodaSilvaBelo How did you do that ?

Often times eglot bugs out and I keep getting this error message:

Process EGLOT (cloud-analytics/(python-mode python-ts-mode)) not running: killed

I suppose that your solution may work for me too.

@BrunodaSilvaBelo this was a bug in Jsonrpc, which I've just fixed, should appear in GNU ELPA soon.

@hydrocat this probably has nothing to do with that, but it's impossible to tell.

One of the reasons I missed this issue, is that it's not according to what an issue should be in the Eglot repo. Please make issues with full reproduction recipes. If you don't have time, just start a discussion instead.