opencode
opencode copied to clipboard
fix(lsp): Clear diagnostics and files maps on client shutdown
Summary
Properly clean up LSP client resources when the underlying LSP server process disconnects or exits.
Fixes #9143 Relates to #5363
Problem
When an LSP client shuts down, the diagnostics Map and files object are not cleared. This can cause:
- Memory retention from diagnostics data for closed files
- Stale data if the same LSP server reconnects
- Memory growth over multiple LSP reconnections
Solution
Add cleanup logic in the LSP client shutdown() method to:
- Clear the
diagnosticsMap - Clear the
filesobject
Changes
-
packages/opencode/src/lsp/client.ts- Add cleanup in shutdown() method
Testing
- [x] TypeScript compilation passes (
bun turbo typecheck) - [x] Unit tests pass (725 tests, 0 failures)
- [x] LSP client tests pass (3 tests)
Note: Manual LSP server disconnect testing was not performed.