emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.79k stars 886 forks source link

Repeated "not running" errors on every keypress #2141

Closed Stebalien closed 4 years ago

Stebalien commented 4 years ago

Describe the bug

After gopls crashes/stops (not sure why), lsp-mode will sometimes output the following every time I press a key (in any buffer, idle timer?). Even if I close all go buffers and shutdown all workspaces, the messages continue and emacs is pretty much unusable (slow) till I restart it.

LSP :: Sending to process failed with the following error: Process gopls<4> not running

To Reproduce

Unfortunately, I don't have a good way to reliably reproduce this. It just happens randomly.

Which Language Server did you use

gopls

OS

Linux (with EXWM)

Version

GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.17.3, Xaw3d scroll bars) of 2020-08-21

**Flags***

"--prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games --with-sound=alsa --with-modules --without-selinux --without-pop --without-gconf --without-gsettings --with-nativecomp --with-x-toolkit=lucid --with-xft --with-xaw3d --without-m17n-flt --with-cairo --without-compress-install 'CFLAGS=-march=native -mtune=native -O2 -pipe -fno-plt -fstack-protector-strong --param=ssp-buffer-size=4 -g -fuse-ld=gold' CPPFLAGS=-D_FORTIFY_SOURCE=2 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now,-z,noexecstack,--hash-style=gnu"
Stebalien commented 4 years ago

Yeah, my timer list is filling up with:

          7148.36          -    #f(compiled-function () #<bytecode -0xfc0f5bdbcc04a0d> [#<hash-table equal 32/65 0x357458f2847> (timer-list-mode :height 1.0 :v-adjust 0.0) remhash])
          7194.85          -    #f(compiled-function () #<bytecode 0x42aaa2ad3981a3> [#<hash-table equal 32/65 0x357458f2847> (messages-buffer-mode) remhash])
          7196.15          -    #f(compiled-function () #<bytecode -0xfbb2e3ab7704a0d> [#<hash-table equal 32/65 0x357458f2847> (helpful-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.16          -    #f(compiled-function () #<bytecode -0xfbb3539daf04a0d> [#<hash-table equal 32/65 0x357458f2847> (exwm-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.16          -    #f(compiled-function () #<bytecode 0xfdb0e2fe0edff3> [#<hash-table equal 233/325 0x357458f224d> ("index.org" :height 1.0 :v-adjust 0.0) remhash])
          7196.16          -    #f(compiled-function () #<bytecode 0xf4fcb739d9fb59b> [#<hash-table equal 32/65 0x357458f2847> (special-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.16          -    #f(compiled-function () #<bytecode -0xfc106b6fa204a0d> [#<hash-table equal 32/65 0x357458f2847> (emacs-lisp-compilation-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.17          -    #f(compiled-function () #<bytecode -0xf64f23ea38d2020> [#<hash-table equal 233/325 0x357458f224d> ("config.yml" :height 1.0 :v-adjust 0.0) remhash])
          7196.17          -    #f(compiled-function () #<bytecode 0xf4feaa94be7b59b> [#<hash-table equal 32/65 0x357458f2847> (eshell-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.17          -    #f(compiled-function () #<bytecode 0xf4fcaf2d997b59b> [#<hash-table equal 32/65 0x357458f2847> (text-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.17          -    #f(compiled-function () #<bytecode 0x3cb17bb4f2df9f> [#<hash-table equal 233/325 0x357458f224d> ("lsp-mode.el" :height 1.0 :v-adjust 0.0) remhash])
          7196.17          -    #f(compiled-function () #<bytecode 0xf4fead4bc97b59b> [#<hash-table equal 32/65 0x357458f2847> (minibuffer-inactive-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.18          -    #f(compiled-function () #<bytecode -0xfca8e4ab6204a0d> [#<hash-table equal 32/65 0x357458f2847> (fundamental-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.18          -    #f(compiled-function () #<bytecode -0xfc0e84c98204a0d> [#<hash-table equal 32/65 0x357458f2847> (debugger-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.18          -    #f(compiled-function () #<bytecode 0xf4fca7a348fb59b> [#<hash-table equal 32/65 0x357458f2847> (help-mode :height 1.0 :v-adjust 0.0) remhash])
          7196.18          -    #f(compiled-function () #<bytecode 0xf4fcb13ec17b59b> [#<hash-table equal 32/65 0x357458f2847> (messages-buffer-mode :height 1.0 :v-adjust 0.0) remhash])
          7199.98          -    #f(compiled-function () #<bytecode 0x42aaa2abc29023> [#<hash-table equal 32/65 0x357458f2847> (minibuffer-inactive-mode) remhash])
          7199.99          -    #f(compiled-function () #<bytecode 0x35716158b71583> [#<hash-table equal 32/65 0x357458f2847> (timer-list-mode) remhash])

(edit: maybe this is normal?)

acristoffers commented 4 years ago

This problem also happens with TeXLab. And I just found out that it can happen after you close the buffer. I opened a project, edited a file, recompiled and deleted the workspace, but kept Emacs running. After some time (I went to YouTube, not sure how long it took) the error was there. It also happens randomly, but I can say that TeXLab crashes/quits a lot, because every now and then I have messages about reconnections, which I don't see when using the Python server.

In my case, it is Emacs from the homebrew cask on macOS Catalina (both up-to-date).

yyoncho commented 4 years ago

are you able to reproduce with the latest lsp-mode? Can you post the value of lsp-on-idle-hook in those buffers?

acristoffers commented 4 years ago

Ok, error happened, but I cannot find the lsp-on-idle-hook method on M-x. Should I run it from somewhere else?

yyoncho commented 4 years ago

Yes, use M-: lsp-on-idle-hook RET.

yyoncho commented 4 years ago

Also it will be nice if you can provide a callstack, available after M-x toggle-debug-on-error.

acristoffers commented 4 years ago

lsp--on-idle-hook:

Debugger entered--Lisp error: (void-variable lsp--on-idle-hook)
  eval(lsp--on-idle-hook t)
  #f(compiled-function (exp &optional insert-value no-truncate char-print-limit) "Evaluate EXP and print value in the echo area.\nWhen called interactively, read an Emacs Lisp expression and\nevaluate it.  Value is also consed on to front of the variable\n`values'.  Optional argument INSERT-VALUE non-nil (interactively,\nwith a non `-' prefix argument) means insert the result into the\ncurrent buffer instead of printing it in the echo area.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'.  When NO-TRUNCATE is\nnon-nil (interactively, with a prefix argument of zero), however,\nthere is no such truncation.\n\nIf the resulting value is an integer, and CHAR-PRINT-LIMIT is\nnon-nil (interactively, unless given a non-zero prefix argument)\nit will be printed in several additional formats (octal,\nhexadecimal, and character).  The character format is used only\nif the value is below CHAR-PRINT-LIMIT (interactively, if the\nprefix argument is -1 or the value doesn't exceed\n`eval-expression-print-maximum-character').\n\nRuns the hook `eval-expression-minibuffer-setup-hook' on entering the\nminibuffer.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive #f(compiled-function () #<bytecode 0x1ff509f8abe1>)) #<bytecode 0x40ce4b13>)(lsp--on-idle-hook nil nil 127)
  apply(#f(compiled-function (exp &optional insert-value no-truncate char-print-limit) "Evaluate EXP and print value in the echo area.\nWhen called interactively, read an Emacs Lisp expression and\nevaluate it.  Value is also consed on to front of the variable\n`values'.  Optional argument INSERT-VALUE non-nil (interactively,\nwith a non `-' prefix argument) means insert the result into the\ncurrent buffer instead of printing it in the echo area.\n\nNormally, this function truncates long output according to the\nvalue of the variables `eval-expression-print-length' and\n`eval-expression-print-level'.  When NO-TRUNCATE is\nnon-nil (interactively, with a prefix argument of zero), however,\nthere is no such truncation.\n\nIf the resulting value is an integer, and CHAR-PRINT-LIMIT is\nnon-nil (interactively, unless given a non-zero prefix argument)\nit will be printed in several additional formats (octal,\nhexadecimal, and character).  The character format is used only\nif the value is below CHAR-PRINT-LIMIT (interactively, if the\nprefix argument is -1 or the value doesn't exceed\n`eval-expression-print-maximum-character').\n\nRuns the hook `eval-expression-minibuffer-setup-hook' on entering the\nminibuffer.\n\nIf `eval-expression-debug-on-error' is non-nil, which is the default,\nthis command arranges for all errors to enter the debugger." (interactive #f(compiled-function () #<bytecode 0x1ff507590895>)) #<bytecode 0x40ce4b13>) (lsp--on-idle-hook nil nil 127))
  eval-expression(lsp--on-idle-hook nil nil 127)
  funcall-interactively(eval-expression lsp--on-idle-hook nil nil 127)
  call-interactively(eval-expression nil nil)
  command-execute(eval-expression)

toggle-debug-on-error does nothing (the bug icon appears, meaning it is active, but there is no action, like not hitting a breakpoint).

acristoffers commented 4 years ago

Wait, it is lsp-on-idle-hook with only one dash. But running that does nothing.

acristoffers commented 4 years ago

I think M-: outputs to the "status bar", which is beign immediatly overwritten by the error message. As I'm using Doom-Emacs, I ran SPC-h-v (describe-variable) and selected lsp-on-idle-hook, which outputed this on a temporary buffer:

Value in #<buffer introduction.tex>
(lsp-modeline--check-code-actions
 lsp--document-links
 lsp--document-highlight
 t)
acristoffers commented 4 years ago

Profiler outputs this:

- command-execute                                                                             20833  94%
 - call-interactively                                                                         20833  94%
  - funcall-interactively                                                                     20833  94%
   - evil-record-macro                                                                        20833  94%
    - apply                                                                                   20833  94%
     - #<compiled 0x1ff508a6818d>                                                             20830  94%
      - error                                                                                 20830  94%
       - signal                                                                               20830  94%
        - debug                                                                               20830  94%
         - recursive-edit                                                                     13835  62%
          - #<compiled 0x1ff5090dd7a9>                                                         3103  14%
           - lsp--parser-on-message                                                            2682  12%
            - lsp--on-request                                                                  1755   7%
             - lsp--send-request-response                                                      1558   7%
                lsp--send-no-wait                                                              1553   7%
                lsp--make-message                                                                 3   0%
             + lsp--build-workspace-configuration-response                                      196   0%
            - lsp--on-notification                                                              908   4%
             - lsp--on-diagnostics                                                              901   4%
              - lsp--uri-to-path                                                                810   3%
               - lsp--uri-to-path-1                                                             789   3%
                - url-generic-parse-url                                                         418   1%
                 - #<compiled 0x1ff5075902f1>                                                   366   1%
                  - kill-buffer                                                                 286   1%
                   + run-hooks                                                                  215   0%
                   + replace-buffer-in-windows                                                   17   0%
                   + magit-preserve-section-visibility-cache                                      8   0%
                   + #<compiled 0x1ff50a604d65>                                                   6   0%
                   + #<compiled 0x1ff509cb8c25>                                                   5   0%
                   + doom-protect-fallback-buffer-h                                               4   0%
                     process-kill-buffer-query-function                                           2   0%
                   + save-place-to-alist                                                          2   0%
                     preview-kill-buffer-cleanup                                                  1   0%
                     uniquify-kill-buffer-function                                                1   0%
                     persp-kill-buffer-query-function                                             1   0%
                 + generate-new-buffer                                                           34   0%
                  url-unhex-string                                                               20   0%
                  -some                                                                           1   0%
               + -keep                                                                           10   0%
                 -compose                                                                         5   0%
              + run-hooks                                                                        53   0%
              + lsp--idle-reschedule                                                             26   0%
            + #<compiled 0x1ff5090979e5>                                                          6   0%
              lsp:json-response-id                                                                1   0%
           + mapcar                                                                              10   0%
             split-string                                                                         6   0%
             lsp--get-body-length                                                                 1   0%
             apply                                                                                1   0%
          - command-execute                                                                    3090  13%
           + call-interactively                                                                3006  13%
          + redisplay_internal (C function)                                                    1101   4%
          + timer-event-handler                                                                 412   1%
          + #<compiled 0x1ff508a4f995>                                                          216   0%
          + flycheck-handle-signal                                                               64   0%
          + evil-repeat-pre-hook                                                                 20   0%
          + doom--after-call-evil-snipe-h                                                        19   0%
            undefined                                                                            10   0%
          + doom--after-call-evil-escape-h                                                       10   0%
          + doom--after-call-evil-snipe-h                                                         8   0%
          + doom--after-call-evil-easymotion-h                                                    7   0%
          + sp--save-pre-command-state                                                            7   0%
          + doom--after-call-evil-easymotion-h                                                    6   0%
          + doom--after-call-evil-escape-h                                                        6   0%
          + winner-save-old-configurations                                                        6   0%
          + evil-repeat-post-hook                                                                 4   0%
          + evil-escape-pre-command-hook                                                          2   0%
            posframe-run-hidehandler                                                              2   0%
          + which-key--hide-popup                                                                 1   0%
            yas--post-command-handler                                                             1   0%
          + preview-move-point                                                                    1   0%
          + eldoc-pre-command-refresh-echo-area                                                   1   0%
          + evil--jump-hook                                                                       1   0%
     - #<compiled 0x40cae785>                                                                     3   0%
      - display-buffer                                                                            3   0%
       - apply                                                                                    3   0%
        - doom-run-switch-buffer-hooks-a                                                          3   0%
         - if                                                                                     3   0%
          - let                                                                                   3   0%
           - let*                                                                                 3   0%
            - and                                                                                 2   0%
             - apply                                                                              2   0%
              - #<compiled 0x40f12fc7>                                                            2   0%
               - display-buffer--maybe-pop-up-frame-or-window                                     2   0%
                - display-buffer--maybe-pop-up-window                                             2   0%
                 - display-buffer-pop-up-window                                                   2   0%
                  - window--display-buffer                                                        1   0%
                   - set-window-buffer                                                            1   0%
                    - apply                                                                       1   0%
                     - ad-Advice-set-window-buffer                                                1   0%
                        #<subr set-window-buffer>                                                 1   0%
                  - window--try-to-split-window                                                   1   0%
                     split-window-sensibly                                                        1   0%
            - if                                                                                  1   0%
             - progn                                                                              1   0%
              - save-current-buffer                                                               1   0%
               - run-hooks                                                                        1   0%
                - doom-auto-revert-buffer-h                                                       1   0%
                 - if                                                                             1   0%
                  - let                                                                           1   0%
                   - auto-revert-handler                                                          1   0%
                      buffer-stale--default-function                                              1   0%
+ ...                                                                                          1249   5%
acristoffers commented 4 years ago

Also got this from debugger (no idea how I got here):

Debugger entered--Lisp error: (error "Process texlab not running")
  process-send-string(#<process texlab> "Content-Length: 67\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":\"$...")
  lsp--send-no-wait("Content-Length: 67\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":\"$..." #<process texlab>)
  #f(compiled-function (it) #<bytecode 0x1ff5074b3349>)(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 12/12 0x1ff509d13a05> :registered-server-capabilities nil :root "/Users/alan/Google Drive/CEFET/Mestrado/Disciplina..." :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff50a9f9471>) :test\? #f(compiled-function () #<bytecode 0x1ff509e6a871>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff509f9d0b5> :request-handlers #<hash-table equal 0/65 0x1ff509f9d0d5> :response-handlers #<hash-table eql 0/65 0x1ff50a6963b5> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff50a6963d5> :action-handlers #<hash-table equal 0/65 0x1ff507ad2eb9> :major-modes (plain-tex-mode latex-mode) :activation-fn nil :priority 1 :server-id texlab :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x1ff507ad2ed9> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc #<process texlab> :cmd-proc #<process texlab> :buffers nil :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff507c25b3d> :watches #<hash-table equal 0/65 0x1ff509e82db5> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action shutdown :diagnostics #<hash-table equal 0/65 0x1ff509e830ad> :work-done-tokens #<hash-table equal 0/65 0x1ff509e832dd>))
  mapcar(#f(compiled-function (it) #<bytecode 0x1ff5074b3349>) (#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 12/12 0x1ff509d13a05> :registered-server-capabilities nil :root "/Users/alan/Google Drive/CEFET/Mestrado/Disciplina..." :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff50a9f9471>) :test\? #f(compiled-function () #<bytecode 0x1ff509e6a871>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff509f9d0b5> :request-handlers #<hash-table equal 0/65 0x1ff509f9d0d5> :response-handlers #<hash-table eql 0/65 0x1ff50a6963b5> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff50a6963d5> :action-handlers #<hash-table equal 0/65 0x1ff507ad2eb9> :major-modes (plain-tex-mode latex-mode) :activation-fn nil :priority 1 :server-id texlab :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x1ff507ad2ed9> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc #<process texlab> :cmd-proc #<process texlab> :buffers nil :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff507c25b3d> :watches #<hash-table equal 0/65 0x1ff509e82db5> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action shutdown :diagnostics #<hash-table equal 0/65 0x1ff509e830ad> :work-done-tokens #<hash-table equal 0/65 0x1ff509e832dd>)))
  lsp--send-notification((:jsonrpc "2.0" :method "$/cancelRequest" :params (:id 15259)))
  lsp-notify("$/cancelRequest" (:id 15259))
  #f(compiled-function (it) #<bytecode 0x1ff5074b331d>)(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 12/12 0x1ff509d13a05> :registered-server-capabilities nil :root "/Users/alan/Google Drive/CEFET/Mestrado/Disciplina..." :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff50a9f9471>) :test\? #f(compiled-function () #<bytecode 0x1ff509e6a871>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff509f9d0b5> :request-handlers #<hash-table equal 0/65 0x1ff509f9d0d5> :response-handlers #<hash-table eql 0/65 0x1ff50a6963b5> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff50a6963d5> :action-handlers #<hash-table equal 0/65 0x1ff507ad2eb9> :major-modes (plain-tex-mode latex-mode) :activation-fn nil :priority 1 :server-id texlab :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x1ff507ad2ed9> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc #<process texlab> :cmd-proc #<process texlab> :buffers nil :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff507c25b3d> :watches #<hash-table equal 0/65 0x1ff509e82db5> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action shutdown :diagnostics #<hash-table equal 0/65 0x1ff509e830ad> :work-done-tokens #<hash-table equal 0/65 0x1ff509e832dd>))
  mapcar(#f(compiled-function (it) #<bytecode 0x1ff5074b331d>) (#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 12/12 0x1ff509d13a05> :registered-server-capabilities nil :root "/Users/alan/Google Drive/CEFET/Mestrado/Disciplina..." :client #s(lsp--client :language-id nil :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode 0x1ff50a9f9471>) :test\? #f(compiled-function () #<bytecode 0x1ff509e6a871>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff509f9d0b5> :request-handlers #<hash-table equal 0/65 0x1ff509f9d0d5> :response-handlers #<hash-table eql 0/65 0x1ff50a6963b5> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff50a6963d5> :action-handlers #<hash-table equal 0/65 0x1ff507ad2eb9> :major-modes (plain-tex-mode latex-mode) :activation-fn nil :priority 1 :server-id texlab :multi-root nil :initialization-options nil :custom-capabilities nil :library-folders-fn nil :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? nil :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn nil :async-request-handlers #<hash-table equal 0/65 0x1ff507ad2ed9> :download-server-fn nil :download-in-progress? nil :buffers nil) :host-root nil :proc #<process texlab> :cmd-proc #<process texlab> :buffers nil :semantic-highlighting-faces nil :semantic-highlighting-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff507c25b3d> :watches #<hash-table equal 0/65 0x1ff509e82db5> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action shutdown :diagnostics #<hash-table equal 0/65 0x1ff509e830ad> :work-done-tokens #<hash-table equal 0/65 0x1ff509e832dd>)))
  lsp--cancel-request(15259)
  #f(compiled-function (&rest _) #<bytecode 0x1ff507c71cb5>)()
acristoffers commented 4 years ago

The compiled function on the last line has this bytecode:

byte code:
  doc:   ...
  args: (&rest rest)
0       constant  post-command-hook
1       constant  post-command-hook
2       eq        
3       goto-if-nil-else-pop 1
6       current-buffer 
7       constant  #<killed buffer>
8       equal     
9:1     not       
10      goto-if-nil-else-pop 3
13      constant  lsp--request-cleanup-hooks
14      constant  15259
15      call      1
16      discard   
17      constant  (#s(lsp--workspace nil #s(hash-table size 12 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("completionProvider" #s(hash-table size 2 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("resolveProvider" t "triggerCharacters" ["\\" "{" "}" "@" "/" " "])) "definitionProvider" t "documentFormattingProvider" t "documentHighlightProvider" t "documentLinkProvider" #s(hash-table size 1 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("resolveProvider" nil)) "documentSymbolProvider" t "foldingRangeProvider" t "hoverProvider" t "referencesProvider" t "renameProvider" #s(hash-table size 1 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("prepareProvider" t)) "textDocumentSync" #s(hash-table size 3 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("change" 1 "openClose" t "save" #s(hash-table size 1 test equal rehash-size 1.5 rehash-threshold 0.8125 data ("includeText" nil)))) "workspaceSymbolProvider" t)) nil "/Users/alan/Google Drive/CEFET/Mestrado/Disciplinas/Sitemas Lineares/Valter/Lista 1/Latex" #s(lsp--client nil nil (:connect #[1028 "\302\300!\303!\304!\305\306\"\307\310\311\312\313\305\314  \"\315\316\317\f\320\321\322\323\324&\325\326\"\210\325\327!\326\"\210r\330!q\210\331 \210)\211B\266\202)\207" ["texlab" process-environment lsp-resolve-final-function generate-new-buffer-name lsp--compute-process-environment format "*%s::stderr*" make-process :name :connection-type pipe :buffer "*%s*" :coding no-conversion :command :filter :sentinel :stderr :noquery t set-process-query-on-exit-flag nil get-buffer-process get-buffer special-mode] 26 "\n\n(fn FILTER SENTINEL NAME ENVIRONMENT-FN)"] :test\? #[0 "\301\302\300!!\207" ["texlab" lsp-server-present\? lsp-resolve-final-function] 3]) nil nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data ()) nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) (plain-tex-mode latex-mode) nil 1 texlab nil nil nil nil nil nil nil nil nil nil nil nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) nil nil nil) nil #<process texlab> #<process texlab> nil nil nil nil initialized #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) nil 0 nil shutdown #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ()) #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8125 data ())))
18      varbind   lsp--buffer-workspaces
20      constant  lsp--cancel-request
21      constant  15259
22      call      1
23      discard   
24      constant  nil
25      goto-if-nil 2
28      constant  nil
29      call      0
30      discard   
31:2    unbind    1
32      constant  lsp-log
33      constant  "Cancelling %s(%s) in hook %s"
34      constant  "textDocument/documentLink"
35      constant  15259
36      constant  post-command-hook
37      call      4
38:3    return    
acristoffers commented 4 years ago

The variables lsp--buffer-workspaces and lsp--cur-workspace still list 2 workspaces with texlab on them, even after all buffers and workspaces were closed. lsp--cur-workspace has the same value of lsp--buffer-workspace even if I delete all workspaces and start a new one.

hungyiloo commented 4 years ago

This is happening for me too:

LSP :: Sending to process failed with the following error: Process ts-ls not running [46 times]

It always seems to occur after I close buffers, persp-mode workspaces, etc. It happens intermittently for me too, not all the time. There seems to be no way to reliably reproduce it. Currently I'm on commit b4e8a1c864 of lsp-mode, but this has been a problem since I started using lsp-mode a month ago. I've been mostly keeping lsp-mode updated.

Is it worth noting that in this state these errors are being generated on every buffer now, even ones that aren't meant to be handled by lsp-mode or the language server?

Evaluating lsp-on-idle-hook gives me

Evaluating...
nil
LSP :: Sending to process failed with the following error: Process ts-ls not running [190 times]

Toggling toggle-debug-on-error and setting lsp-print-io to t doesn't seem let me generate a callstack, even though the errors keep appearing. My *lsp-log* buffer is overwhelmingly filled with:

Cancelling textDocument/codeAction(720) in hook post-command-hook
Cancelling textDocument/codeAction(720) in hook post-command-hook
Cancelling textDocument/codeAction(720) in hook post-command-hook
Cancelling textDocument/codeAction(720) in hook post-command-hook
...

I've tried everything to reset lsp-mode to stop the errors but the only thing that's worked so far is to restart Emacs. I will try updating once more to latest lsp-mode to see if I get it again. It happens about once every 2 days for me.

Language Server typescript-language-server

OS Ubuntu 20.04 under WSL2 on Windows 10 running GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) feature/native-comp (67c5369156)

yyoncho commented 4 years ago

Proposed fix at #2149 .

yyoncho commented 4 years ago

2149 is a fix for @hungyiloo's report but most likely the others are hitting that issue as well.

acristoffers commented 4 years ago

I think it is the same problem, but I'm not sure that will fix it, however I just started using emacs the other day and I'm not really familiar with it nor elisp. But what I saw while trying to debug is that a reference to closed workspaces, which contain no buffers but do contain references to a dead texlab process, was lingering around, and lsp was trying to send the cancel request to that process.

And I figured what I had to do to make the debugger pop up: (setq debug-on-signal t) and (toggle-debug-on-error).

yyoncho commented 4 years ago

@acristoffers sounds like the same problem. We were leaving stale cleanup handler at post-command-hook.

acristoffers commented 4 years ago

It took me longer to understand the effects of your change than it should. 🙈 Now I can see how that fixes the issue. Thank you for your time (and patience).

yyoncho commented 4 years ago

Pushed the fix, please confirm that it solves your issue.

Stebalien commented 4 years ago

I haven't seen it since, but I'll let you know if it comes back. Thanks for the quick fix!

unhammer commented 2 years ago

With lsp-mode 8.0.0 I can still get into this state where post-command-hook has the cleanup hooks, but lsp--request-cleanup-hooks has no elements, so it keeps trying to clean up again and again (in my case, for four different id's on a workspace I've called lsp-workspace-shutdown on).

tinloaf commented 3 months ago

@unhammer I still get into the same state with lsp-mode 20240701.633.

lsp--request-cleanup-hooks is not empty for me, but I don't know how to figure out what's in it:

lsp--request-cleanup-hooks is a variable defined in ‘lsp-mode.el’.

Its value is #<hash-table equal 0/24 0x102eeae5ea08 ...>

How did you solve that problem yourself?

unhammer commented 3 months ago

I never solved this