Skip to content
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

SourceKit Language Server stops response everytime after seconds of use #646

Closed
MiKayule opened this issue Nov 29, 2023 · 10 comments
Closed
Labels
bug Something isn't working sourcekit-lsp SourceKit-LSP issue windows Issue specific to Windows

Comments

@MiKayule
Copy link

MiKayule commented Nov 29, 2023

Describe the bug
Everytime I open a Swift code file, vscode-swift start running, after a few seconds of typing codes, the SourceKit Language Server won't response anymore. Only kill the sourcekit-lsp.exe with Task Manager, change LSP settings to restart the language server or restart VSCode can fix it for a moment, then it get unresponsive again.

Even during the period it runs normally, I often feel it laggy, which feels like it got unresponsive and recovered by itself after one or two seconds, but finally it will get completely unresponsive.

To Reproduce
Steps to reproduce the behavior:

  1. Open an one-file Swift source
  2. Type some code, use the auto completion like usual
  3. Everything get stucked, e.g. the red line won't disappear even after being fixed
  4. In trace window, there's only a lot of message of "Sending notification" and "Sending request", but no "Received" messages anymore

Expected behavior
Work normally just like language servers for other languages

Environment

  • OS: Windows 11 23H2 (22631.2715)
  • Swift version (output of swift --version): Swift version 5.9.1 (swift-5.9.1-RELEASE) Target: x86_64-unknown-windows-msvc
  • Visual Studio Code version: 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e)
  • vscode-swift version: v1.7.0

Additional context
I set "swift.sourcekit-lsp.trace.server" to "messages", here's a screenshot of the situation
image

@MiKayule MiKayule added the bug Something isn't working label Nov 29, 2023
@MiKayule
Copy link
Author

In addition, after it gets responsive, I change LSP settings, press OK to restart the language server, on the output window for Swift, it shows as:

11:03:37: SourceKit-LSP setup
11:03:37: Swift version 5.9.1 (swift-5.9.1-RELEASE)
11:03:37: focus: undefined
11:04:53: SourceKit-LSP setup
11:04:53: Error: Stopping the server timed out

(I restarted language server at 11:04:53)

@adam-fowler
Copy link
Contributor

Can you report this in the https://github.com/apple/sourcekit-lsp repo.

This is most likely an issue with sourcekit-lsp itself.

@adam-fowler
Copy link
Contributor

The timeout issue appears to be an issue with VSCode itself. Restarting an LSP server on Windows doesn't register it has killed the original process. So I have to catch the timeout and assume it has killed the process.

@adam-fowler
Copy link
Contributor

Would you be able to verify if these issues are resolved when using swift 5.8. I have another very similar issue which is resolved by using swift 5.8. I realise this is not a solution but it allows us to narrow down where the issue is coming from.

By the way I added this apple/sourcekit-lsp#982

@adam-fowler adam-fowler added the sourcekit-lsp SourceKit-LSP issue label Nov 29, 2023
@MiKayule
Copy link
Author

Tried with Swift 5.8.1, everything works fine.

PS > swift --version
compnerd.org Swift version 5.8.1 (swift-5.8.1-RELEASE)
Target: x86_64-unknown-windows-msvc

@adam-fowler
Copy link
Contributor

Thanks that narrows it down. Let's see if the sourcekit-lsp guys come up with anything.

@litewrap
Copy link

litewrap commented Dec 4, 2023

I have the same problem here VSCode 1.84.2 with Swift 5.9.1 on Windows 11. The moment I type Foundation. or WinSDK. , LSP Server take full CPU usage, issuing the command to restart LSP Server don't resolve, LSP Server constantly unresponsive.
No problems with Swift 5.8.1.

@litewrap
Copy link

litewrap commented Dec 5, 2023

Good news from Alex Hoppen
apple/sourcekit-lsp#982

I confirm the fix is working with current main dev snapshot (Swift 5.11).

Thanks Swift Team !

@adam-fowler
Copy link
Contributor

I wasn't sure if those changes had made it into a snapshot, obviously they have now. That's great news.

@adam-fowler
Copy link
Contributor

As this is fixed and been cherry-picked for latest 5.9. It isn't part of a release yet it will be soon so I'm going to close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sourcekit-lsp SourceKit-LSP issue windows Issue specific to Windows
Projects
None yet
Development

No branches or pull requests

3 participants