LSP client never sends textDocument/didClose (follow-up to #64276, closed by the stale bot and locked)

Status Open
Reported on v2.1.266
Maintainer reply None cached
Activity 0 comments · opened Sep 9, 2026

What's Wrong?

#64276 reported this with a Lean server (one worker process per open file, 51 workers, ~100 GB RSS). It was closed as not planned by the stale bot without a maintainer decision and is now locked, so I am filing the follow-up with a fresh measurement.

On 2.1.266 the client sends textDocument/didOpen for each file the LSP tool touches and never textDocument/didClose: over a session the notifications on the server's stdin are initialized and didOpen only (recorded with a wrapper in the server's place; the same on 2.1.259 and 2.1.261 across 29 debug logs, https://github.com/tagawa0525/lsp-det/blob/main/docs/research/claude-code-dogfooding.md, round 4). Beyond the resource growth in #64276, this has a correctness consequence: LSP says that while a document is open its content is owned by the client, so the server must not read the file from disk. A file the agent opened once through the LSP tool and later changed with Bash, git, or a formatter stays at its didOpen content for the rest of the session, even for a server that would otherwise re-read it.

What Should Happen?

Send didClose when the tool is done with a document (or keep a bounded set of open documents and close the least recently used), so that servers can release per-document state and go back to the file on disk.

Error Messages/Logs

None; the notification is simply absent. Recorded stdin of the server for one findReferences on 2.1.266: initialize, initialized, textDocument/didOpen, textDocument/references, shutdown.

Steps to Reproduce

  1. Any plugin .lsp.json (rust-analyzer here) and a project.
  2. Put a recorder in the server's place (https://github.com/tagawa0525/lsp-det/tree/main/scripts/claude-code/tee-probe) and run claude -p "Use the LSP tool: findReferences on …, then hover on …" --plugin-dir <plugin> --allowedTools LSP.
  3. grep -c didClose <log> is 0.

Claude Model any (Sonnet here). Is this a regression? No. Claude Code Version 2.1.266. Platform CLI. Operating System Linux (NixOS). Terminal/Shell bash

View original on GitHub ↗