Skip to content

Emacs freezes when working with lsp-typescript #4727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 of 3 tasks
magandrez opened this issue Mar 5, 2025 · 0 comments
Open
2 of 3 tasks

Emacs freezes when working with lsp-typescript #4727

magandrez opened this issue Mar 5, 2025 · 0 comments
Labels

Comments

@magandrez
Copy link

magandrez commented Mar 5, 2025

Thank you for the bug report

  • I am using the latest version of lsp-mode related packages.
  • I checked FAQ and Troubleshooting sections
  • You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

I have come across a persisting performance degradation when utilizing LSP on a Typescript codebase.

Emacs freezes for several seconds when typing on any Typescript file no matter what configuration, with or without emacs-lsp-booster activated.

I first parsed this as an issue with orderless package, raised here oantolin/orderless#186, but maintainer pointed out that is most likely an LSP problem, as lsp-completion-passthrough-all-completions is the function with the largest footprint on the profiler report.

Steps to reproduce

  • Setup LSP (lsp-typescript) with configuration provided to work on a relatively large TS project.
  • Move around the code given a .ts file, and start working on the file.
  • See Emacs freezing for 2+ seconds every few keystrokes.

Expected behavior

Emacs is responsive while working with lsp-typescript on TS/JS files.

Which Language Server did you use?

lsp-typescript is the LSP server. I use typescript-language-server the output of ts-ls utilizing emacs-lsp-booster below:

[2025-03-05T10:47:18Z INFO  emacs_lsp_booster::app] About to run the lsp server with command "typescript-language-server" "--stdio"
[2025-03-05T10:47:18Z INFO  emacs_lsp_booster::app] Will convert server json to bytecode! bytecode options: BytecodeOptions { object_type: Plist, null_value: Nil, false_value: Nil }

OS

Linux

Error callstack

lsp-log shows a lot of textDocument/hover logs while moving around the TS file:

The following clients were selected based on priority: (server-id ts-ls, priority -2)
Cancelling textDocument/hover(556) in hook after-change-functions
Cancelling textDocument/hover(557) in hook after-change-functions
Cancelling textDocument/hover(562) in hook after-change-functions
Cancelling textDocument/hover(564) in hook after-change-functions
Cancelling textDocument/hover(568) in hook after-change-functions
Cancelling textDocument/hover(578) in hook after-change-functions
Cancelling textDocument/codeAction(574) in hook after-change-functions
Cancelling textDocument/hover(579) in hook after-change-functions
Cancelling textDocument/hover(580) in hook after-change-functions
Cancelling textDocument/documentHighlight(584) in hook after-change-functions
Cancelling textDocument/codeAction(583) in hook after-change-functions
Cancelling textDocument/hover(581) in hook after-change-functions
Cancelling textDocument/hover(585) in hook after-change-functions
Cancelling textDocument/hover(587) in hook after-change-functions
Cancelling textDocument/hover(591) in hook after-change-functions
Cancelling textDocument/hover(598) in hook after-change-functions
Cancelling textDocument/hover(599) in hook after-change-functions
Cancelling textDocument/hover(600) in hook after-change-functions
Cancelling textDocument/hover(601) in hook after-change-functions
Cancelling textDocument/hover(602) in hook after-change-functions
Cancelling textDocument/hover(604) in hook after-change-functions
Cancelling textDocument/hover(613) in hook after-change-functions
Cancelling textDocument/hover(614) in hook after-change-functions
Cancelling textDocument/hover(615) in hook after-change-functions
Cancelling textDocument/hover(616) in hook after-change-functions
Cancelling textDocument/hover(617) in hook after-change-functions
Cancelling textDocument/hover(619) in hook after-change-functions
Cancelling textDocument/codeAction(635) in hook after-change-functions
Cancelling textDocument/hover(634) in hook after-change-functions
Cancelling textDocument/documentHighlight(632) in hook after-change-functions
Cancelling textDocument/hover(637) in hook after-change-functions
Cancelling textDocument/codeAction(645) in hook after-change-functions
Cancelling textDocument/hover(643) in hook after-change-functions
Cancelling textDocument/codeAction(649) in hook after-change-functions
Cancelling textDocument/hover(647) in hook after-change-functions
Cancelling textDocument/documentHighlight(659) in hook after-change-functions
Cancelling textDocument/codeAction(658) in hook after-change-functions
Cancelling textDocument/hover(656) in hook after-change-functions
Cancelling textDocument/codeAction(670) in hook after-change-functions
Cancelling textDocument/hover(669) in hook after-change-functions
Cancelling textDocument/hover(675) in hook after-change-functions
Cancelling textDocument/hover(676) in hook after-change-functions
Cancelling textDocument/hover(679) in hook after-change-functions
Cancelling textDocument/hover(684) in hook after-change-functions
Cancelling textDocument/hover(685) in hook after-change-functions
Cancelling textDocument/hover(686) in hook after-change-functions
Cancelling textDocument/hover(690) in hook after-change-functions
Cancelling textDocument/hover(691) in hook after-change-functions
Cancelling textDocument/hover(692) in hook after-change-functions
Cancelling textDocument/hover(696) in hook after-change-functions
Cancelling textDocument/hover(701) in hook after-change-functions
Cancelling textDocument/hover(702) in hook after-change-functions
Cancelling textDocument/hover(703) in hook after-change-functions
Cancelling textDocument/hover(704) in hook after-change-functions
Cancelling textDocument/hover(705) in hook after-change-functions
Cancelling textDocument/hover(710) in hook after-change-functions
Cancelling textDocument/hover(711) in hook after-change-functions
Cancelling textDocument/hover(712) in hook after-change-functions
Cancelling textDocument/hover(714) in hook after-change-functions
Cancelling textDocument/hover(717) in hook after-change-functions
Cancelling textDocument/hover(722) in hook after-change-functions
Cancelling textDocument/hover(735) in hook after-change-functions
Cancelling textDocument/hover(737) in hook after-change-functions
Cancelling textDocument/hover(740) in hook after-change-functions
Cancelling textDocument/documentHighlight(744) in hook after-change-functions
Cancelling textDocument/codeAction(743) in hook after-change-functions
Cancelling textDocument/hover(741) in hook after-change-functions
Cancelling textDocument/hover(745) in hook after-change-functions
Cancelling textDocument/hover(746) in hook after-change-functions
Cancelling textDocument/hover(748) in hook after-change-functions
Cancelling textDocument/documentHighlight(758) in hook after-change-functions
Cancelling textDocument/codeAction(757) in hook after-change-functions
Cancelling textDocument/hover(755) in hook after-change-functions
Cancelling textDocument/codeAction(762) in hook after-change-functions
Cancelling textDocument/hover(759) in hook after-change-functions
Cancelling textDocument/hover(771) in hook after-change-functions
Cancelling textDocument/codeAction(777) in hook after-change-functions
Cancelling textDocument/hover(775) in hook after-change-functions
Cancelling textDocument/hover(784) in hook after-change-functions
Cancelling textDocument/hover(791) in hook after-change-functions
Cancelling textDocument/hover(797) in hook after-change-functions
Cancelling textDocument/codeAction(804) in hook after-change-functions
Cancelling textDocument/codeAction(883) in hook post-command-hook
Cancelling textDocument/codeAction(887) in hook post-command-hook
Cancelling textDocument/documentHighlight(956) in hook after-change-functions
Cancelling textDocument/codeAction(955) in hook after-change-functions
Cancelling textDocument/hover(962) in hook after-change-functions
Cancelling textDocument/hover(987) in hook after-change-functions
Cancelling textDocument/hover(990) in hook after-change-functions
Cancelling textDocument/hover(993) in hook after-change-functions
Cancelling textDocument/hover(994) in hook after-change-functions
Cancelling textDocument/hover(997) in hook after-change-functions
Cancelling textDocument/hover(1011) in hook after-change-functions
Cancelling textDocument/codeAction(1016) in hook after-change-functions
Cancelling textDocument/hover(1017) in hook after-change-functions
Cancelling textDocument/hover(1021) in hook after-change-functions
Cancelling textDocument/hover(1033) in hook after-change-functions
Cancelling textDocument/hover(1035) in hook after-change-functions
Cancelling textDocument/hover(1039) in hook after-change-functions
Cancelling textDocument/hover(1043) in hook after-change-functions
Cancelling textDocument/hover(1046) in hook after-change-functions
Cancelling textDocument/hover(1047) in hook after-change-functions
Cancelling textDocument/codeAction(1053) in hook after-change-functions
Cancelling textDocument/hover(1049) in hook after-change-functions
Cancelling textDocument/hover(1055) in hook after-change-functions
Cancelling textDocument/hover(1060) in hook after-change-functions
Cancelling textDocument/hover(1063) in hook after-change-functions
Cancelling textDocument/hover(1065) in hook after-change-functions
Cancelling textDocument/hover(1068) in hook after-change-functions
Cancelling textDocument/hover(1070) in hook after-change-functions
Cancelling textDocument/hover(1074) in hook after-change-functions
Cancelling textDocument/hover(1080) in hook after-change-functions
Cancelling textDocument/hover(1081) in hook after-change-functions
Cancelling textDocument/hover(1085) in hook after-change-functions
Cancelling textDocument/hover(1087) in hook after-change-functions

Profiler report below:

       11217  90% - ...
       11217  90%  - completion-all-completions
       11217  90%   - apply
       11217  90%    - #<native-comp-function completion-all-completions>
       11217  90%     - completion--nth-completion
       11217  90%      - seq-some
       11217  90%       - seq-do
       11217  90%        - mapc
       11217  90%         - #<byte-code-function 605>
       11217  90%          - #<byte-code-function 63C>
       11217  90%           - eval
       11217  90%            - let
       11217  90%             - funcall
       11217  90%              - #<byte-code-function E8C>
       10045  81%               - lsp-completion-passthrough-all-completions
       10045  81%                - #<byte-code-function 4C8>
       10045  81%                 - #<byte-code-function 4F9>
       10045  81%                  - lsp-request-while-no-input
       10045  81%                   - sit-for
          24   0%                      redisplay_internal (C function)
           4   0%                    - #<byte-code-function 216>
           4   0%                     - json-parse-buffer
           4   0%                      - apply
           4   0%                       - lsp-booster--advice-json-parse
           4   0%                        - or
           4   0%                         - when
           4   0%                          - if
           4   0%                           - progn
           4   0%                            - let
           4   0%                               read
        1172   9%               - orderless-all-completions
        1168   9%                - orderless--filter
        1168   9%                 - #<native-comp-function F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_56>
        1168   9%                  - complete-with-action
        1168   9%                   - all-completions
          76   0%                    - #<byte-code-function 51F>
          20   0%                     - #<byte-code-function A8C>
          20   0%                        commandp
           4   0%                - orderless--compile
           4   0%                   orderless--ignore-case-p
         687   5% - redisplay_internal (C function)
           7   0%  - redisplay--pre-redisplay-functions
           1   0%     run-hook-with-args
           7   0%  - eval
           7   0%   - if
           7   0%      frame-parameter
           4   0%    file-remote-p
           4   0%  - mode-line-default-help-echo
           4   0%   - window-at-side-p
           4   0%    - window-pixel-edges
           4   0%       window-edges
         377   3% - command-execute
         358   2%  - byte-code
         358   2%   - read-extended-command
         358   2%    - read-extended-command-1
         358   2%     - completing-read
         358   2%      - apply
         358   2%       - completing-read@llama
         358   2%        - #<primitive-function completing-read>
         358   2%         - completing-read-default
         358   2%          - apply
         358   2%           - vertico--advice
         358   2%            - apply
         358   2%             - #<native-comp-function completing-read-default>
          68   0%                redisplay_internal (C function)
          37   0%              - vertico--exhibit
          33   0%               - vertico--update
          21   0%                - redisplay
          21   0%                   redisplay_internal (C function)
          12   0%                - vertico--recompute
          12   0%                 - vertico-sort-history-length-alpha
           4   0%                  - #<native-comp-function F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_14>
           4   0%                     #<primitive-function string-lessp>
           4   0%               - vertico--arrange-candidates
           4   0%                - vertico--affixate
           4   0%                 - #<byte-code-function 1EA>
           4   0%                  - apply
           4   0%                   - marginalia--affixate
           4   0%                    - marginalia--cached
           4   0%                     - marginalia-annotate-command
           4   0%                        marginalia-annotate-binding
           4   0%              - timer-event-handler
           4   0%               - apply
           4   0%                - auto-revert-buffers
           4   0%                 - apply
           4   0%                  - auto-revert-buffers@buffer-list-filter
           4   0%                   - #<native-comp-function auto-revert-buffers>
           4   0%                    - auto-revert--buffer-candidates
           4   0%                       #<native-comp-function F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_27>
          19   0%  - funcall-interactively
          13   0%   - self-insert-command
           9   0%    - sp--post-self-insert-hook-handler
           5   0%     - sp-insert-pair
           5   0%      - sp--get-closing-regexp
           5   0%       - sp--strict-regexp-opt
           5   0%        - #<native-comp-function F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_79>
           5   0%         - sp--regexp-for-group
           5   0%          - regexp-opt
           5   0%           - regexp-opt-group
           5   0%            - regexp-opt-group
           5   0%             - regexp-opt-group
           5   0%              - regexp-opt-charset
           5   0%               - #<byte-code-function 5CB>
           5   0%                  format
           4   0%     - sp--all-pairs-to-insert
           4   0%      - sp--do-action-p
           4   0%       - sp-point-in-string
           4   0%        - sp--syntax-ppss
           4   0%         - syntax-ppss
           4   0%            parse-partial-sexp
           1   0%    - lsp-on-change
           1   0%     - #<byte-code-function 469>
           1   0%      - lsp-notify
           1   0%       - lsp--send-notification
           1   0%        - #<byte-code-function 4E1>
           1   0%         - lsp--send-no-wait
           1   0%          - lsp-process-send
           1   0%           - apply
           1   0%            - #<byte-code-function CC7>
           1   0%               lsp--make-message
           5   0%   - next-line
           5   0%    - line-move
           5   0%       line-move-visual
           1   0%   - backward-kill-word
           1   0%    - kill-word
           1   0%     - kill-region
           1   0%      - filter-buffer-substring
           1   0%       - buffer-substring--filter
           1   0%        - #<byte-code-function A11>
           1   0%         - apply
           1   0%          - #<byte-code-function 9C2>
           1   0%             delete-and-extract-region
          66   0% - timer-event-handler
          46   0%  - apply
          10   0%   - corfu--auto-complete-deferred
          10   0%    - corfu--exhibit
          10   0%     - apply
          10   0%      - #<byte-code-function 8B2>
          10   0%       - apply
          10   0%        - #<byte-code-function B65>
          10   0%         - corfu--update
          10   0%          - redisplay
          10   0%             redisplay_internal (C function)
           9   0%   - #<native-comp-function F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_9>
           9   0%      jit-lock-context-fontify
           8   0%   - show-paren-function
           8   0%    - treesit-show-paren-data
           4   0%     - treesit-show-paren-data--categorize
           4   0%        treesit-node-at
           4   0%     - show-paren--default
           4   0%      - syntax-ppss
           4   0%         parse-partial-sexp
           8   0%     lsp-ui-doc-unfocus-frame
           7   0%   - auto-revert-buffers
           7   0%    - apply
           7   0%     - auto-revert-buffers@buffer-list-filter
           7   0%      - #<native-comp-function auto-revert-buffers>
           5   0%         auto-revert-buffer
           2   0%       - auto-revert--buffer-candidates
           2   0%          auto-revert--polled-buffers
           4   0%   - #<byte-code-function 656>
           4   0%      lsp-ui-sideline--run
          20   0%    cancel-timer-internal
          12   0% - #<byte-code-function 216>
           4   0%  - #<byte-code-function 40A>
           4   0%     kill-buffer
           4   0%  - mapc
           4   0%   - #<byte-code-function 266>
           4   0%    - lsp--parser-on-message
           4   0%     - #<byte-code-function 8A9>
           4   0%      - #<byte-code-function 88E>
           4   0%       - #<byte-code-function 8F3>
           4   0%        - apply
           4   0%         - lsp--modeline-update-code-actions
           4   0%          - lsp-modeline--build-code-actions-string
           4   0%           - lsp-modeline--build-code-actions-segments
           4   0%              #<byte-code-function 718>
           4   0%    substring-no-properties
          12   0% - #<byte-code-function 6F1>
          12   0%    native-elisp-load
           5   0% - delete-selection-pre-hook
           5   0%  - use-region-p
           5   0%     region-active-p

Anything else?

Emacs version: GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.48, cairo version 1.18.2) of 2025-03-01 compiled --with-native-compilation --with-json --with-pgtk from 6a2f6056c5a079a7f3db240171680560a3bd9710

I have followed all the performance recommendations.

Possibly related #4538 #4698

@magandrez magandrez added the bug label Mar 5, 2025
@magandrez magandrez changed the title Emacs freezes when working with lsp-typescript + emacs-lsp-booster on a TS codebase Emacs freezes when working with lsp-typescript Mar 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant