-
Notifications
You must be signed in to change notification settings - Fork 219
Fix high CPU usage when encountering non-file URI workspaces #1396
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
Conversation
The VSCode extension itself already does this but the language server should as well
It’ll fail matching things *anyway* so we can just bail earlier
So I just did testing in a new Neovim 0.11 installation. For a virtual file
There's three things wrong here:
I think it's probably wrong for it to be const { URI } = await import("vscode-uri").then(m => m.default);
console.log(URI.parse('file://.').fsPath)
// logs `/` From a normal initialization we get this:
I'm thinking we could maybe check to see if fsPath resolves to
Either way trying to run at a workspace folder root of |
Hey,
Thanks for the info. I'll open an issue in neovim. |
Fixes #1394
There are two issues here:
file://
URIs and we were getting their filesystem path when ends up being an empty string.foo://bar.html
), causes the server to be initialized with a file URI offile://.
and rootPath of/.
. I'd expect them to use thefoo://
scheme but that does not happen. I think it's super reasonable to have the server refuse a workspace folder that is the filesystem root. This check is definitely not exhaustive (may not handle network shares, arbitrary mounts, different drives on Windows, etc…) but this is probably "good enough" to detect this situation.Both of these results in the folder being treated as
/
and results in a file search from the root causing super high CPU usage. I've also added a check insidegetProject
so files with non-file schemes are ignored. They'll get afsPath
of empty string as well and as such won't match any project. The VSCode extension already does this at the extension level but we weren't doing it in the language server.