[PR #9144] fix(lsp): Clear diagnostics and files maps on client shutdown #13001

Closed
opened 2026-02-16 18:17:53 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9144

State: closed
Merged: No


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:

  1. Memory retention from diagnostics data for closed files
  2. Stale data if the same LSP server reconnects
  3. Memory growth over multiple LSP reconnections

Solution

Add cleanup logic in the LSP client shutdown() method to:

  • Clear the diagnostics Map
  • Clear the files object

Changes

  • packages/opencode/src/lsp/client.ts - Add cleanup in shutdown() method

Testing

  • TypeScript compilation passes (bun turbo typecheck)
  • Unit tests pass (725 tests, 0 failures)
  • LSP client tests pass (3 tests)

Note: Manual LSP server disconnect testing was not performed.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9144 **State:** closed **Merged:** No --- ## 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: 1. Memory retention from diagnostics data for closed files 2. Stale data if the same LSP server reconnects 3. Memory growth over multiple LSP reconnections ## Solution Add cleanup logic in the LSP client `shutdown()` method to: - Clear the `diagnostics` Map - Clear the `files` object ## 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.
yindo added the pull-request label 2026-02-16 18:17:53 -05:00
yindo closed this issue 2026-02-16 18:17:53 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13001