-
-
Notifications
You must be signed in to change notification settings - Fork 961
Description
Thank you for the bug report
- I am using the latest version of
lsp-moderelated 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 was wondering why visiting the first file in a Rust project froze Emacs for a minute or so on a very fast machine, consuming 100% of CPU all that time.
Turns out that lsp-watch-root-folder used for workspace/didChangeWatchedFiles walks the directory recursively using lsp--all-watchable-directories and it follows symlinks even when they point outside the root folder. In my case it ended up traversing the out-of-tree build directory which may contain over 200000 subdirectories IIRC and from there it even found its way to /var/log.
When debugging I also noticed that rust-analyzer provides glob patterns that limit what should actually be watched but lsp-mode seems to ignore them. In a large repository with lots of subprojects this may cause Emacs to watch a lot of unnecessary directories.
Steps to reproduce
- Create for example a Rust project and inside it create a symlink to, say, /var
- Add logging to lsp--all-watchable-directories or put a breakpoint to it using edebug or use some tracing feature.
- Open a file inside the project so that rust-analyzer gets started for the project.
- Observe the directories that lsp--all-watchable-directories traverses.
Expected behavior
- lsp-watch-root-folder does not follow symlinks outside the root folder, at least not by default.
- glob patterns provided by LSP server are used to limit what is watched
Which Language Server did you use?
rust-analyzer
OS
Linux
Error callstack
Anything else?
No response