Description
After some completion requests, language services stop responding (can't ctrl+click, hover says "Loading..." forever, no more completion, etc). This makes SourceKit-LSP hardly usable and seems like a recent-ish regression (~3 weeks?)
Repro
- Open a file and type
let foo = 0
S
- Hover over
foo
, its description pops up - After
S
, type7
- Hover over
foo
, its description still pops up - Erase
7
and typee
- Hover over
foo
, seeLoading...
forever
Expected
Language services continue working.
Environment
Swift:
Swift version 5.9-dev (LLVM ccba7f42fded680, Swift f5fbee2f26addeb)
Target: x86_64-unknown-windows-msvc
VSCode:
Version: 1.78.2 (user setup)
Commit: b3e4e68a0bc097f0ae7907b217c1119af9e03435
Date: 2023-05-10T14:39:26.248Z (4 wks ago)
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621
Sandboxed: No
Swift extension:
Name: Swift
Id: sswg.swift-lang
Description: Swift Language Support for Visual Studio Code.
Version: 1.3.0
Publisher: Swift Server Work Group
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Investigation
I locally rebuilt SourceKit-LSP with only support for textDocument/completion
and textDocument/hover
and can repro this (except that I don't get squiggles, expectedly). However I cannot repro it after disabling textDocument/completion
.
Curiously, SourceKit-LSP keeps logging valid request/response pairs, but it seems like VSCode never processes them.
The only difference in LSP logging between the S7
and Se
cases are:
Se
results in a massive completion response (173 items), whereasS7
has an empty response- VS Code sends
$/cancelRequest
s after the completion of the hover request in theS7
case:
sourcekit-lsp.exe SourceKitServer: Notification<$/cancelRequest>(
clientID: ObjectIdentifier,
params: CancelRequestNotification(id: 2)
)
sourcekit-lsp.exe SourceKitServer: Notification<$/cancelRequest>(
clientID: ObjectIdentifier,
params: CancelRequestNotification(id: 1)
)
When artificially trimming down the completion response to 50 items in SourceKit-LSP, the issue disappears, even if adding a sleep, so this has to do with the payload size of large completion lists. I dumped the JSON and it is well-formatted to this is not the issue.
Testing different completions and monitoring the size of the resulting json response, it seems like something funny happens around 0xFFFF:
// Not broken: 54362 (Sa)
// Not broken: 63208 (Sr)
// Broken: 69602 (St)
// Broken: 79583 (Se)