()
| 224 | * init: the generation counter invalidates the in-flight promise. |
| 225 | */ |
| 226 | export function reinitializeLspServerManager(): void { |
| 227 | if (initializationState === 'not-started') { |
| 228 | // initializeLspServerManager() was never called (e.g. headless subcommand |
| 229 | // path). Don't start it now. |
| 230 | return |
| 231 | } |
| 232 | |
| 233 | logForDebugging('[LSP MANAGER] reinitializeLspServerManager() called') |
| 234 | |
| 235 | // Best-effort shutdown of any running servers on the old instance so |
| 236 | // /reload-plugins doesn't leak child processes. Fire-and-forget: the |
| 237 | // primary use case (issue #15521) has 0 servers so this is usually a no-op. |
| 238 | if (lspManagerInstance) { |
| 239 | void lspManagerInstance.shutdown().catch(err => { |
| 240 | logForDebugging( |
| 241 | `[LSP MANAGER] old instance shutdown during reinit failed: ${errorMessage(err)}`, |
| 242 | ) |
| 243 | }) |
| 244 | } |
| 245 | |
| 246 | // Force the idempotence check in initializeLspServerManager() to fall |
| 247 | // through. Generation counter handles invalidating any in-flight init. |
| 248 | lspManagerInstance = undefined |
| 249 | initializationState = 'not-started' |
| 250 | initializationError = undefined |
| 251 | |
| 252 | initializeLspServerManager() |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Shutdown the LSP server manager and clean up resources. |
no test coverage detected