VS Code Extension ↔ Language Server: Workspace Folder Closure Timing
0 reputation · 21 Feb 2023, 10:44 UTC
VS Code Extension ↔ Language Server: Workspace Folder Closure Timing
The goal is to understand how the VS Code Extension API’s LanguageClient manages its lifecycle when a workspace folder is closed, compared to when the entire window is reloaded. The documented behavior indicates that the client attempts an automatic restart if the server crashes, but the exact moment when resources are released after a folder closure remains unclear.
Constraints include the fact that the Extension API and the Language Server Protocol (LSP) communicate over JSON‑RPC, typically via stdio or TCP. The behavior may differ between the Desktop client and the Web/Remote versions due to transport limitations. Additionally, memory leaks have been observed when extensions fail to dispose of the LanguageClient instance.
Uncertainty surrounds the cleanup timing: does VS Code dispose of the client immediately upon folder removal, or is disposal deferred until a full window reload? Is there a configuration option to alter this timing, and what triggers the eventual cleanup if the client is not explicitly disposed?
1. Does VS Code dispose of the LanguageClient instance immediately when a workspace folder is closed, or does it wait until the entire window is reloaded?
2. If the client is not disposed, what internal events or conditions trigger the cleanup of its resources?
3. Are there documented settings or API hooks that allow extensions to customize this disposal behavior?