You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stopping a language server over a socket loses the exit notification and logs "Socket closed" #2012
When LSP4IJ stops or restarts a language server that it reaches over a socket, the exit notification often doesn't reach the language server, and the Log tab of the LSP console shows:
java.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.net.SocketException: Socket closed
...
Caused by: org.eclipse.lsp4j.jsonrpc.JsonRpcException: java.net.SocketException: Socket closed
at org.eclipse.lsp4j.jsonrpc.json.StreamMessageConsumer.consume(StreamMessageConsumer.java:72)
at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$8(LanguageServerWrapper.java:696)
A language server that LSP4IJ started is then ended without having received exit, instead of exiting by itself.
Steps
Use a language server that LSP4IJ starts with SocketStreamConnectionProvider.startAndAccept, one that connects to --socket <port>. User-defined language servers with a socket transport use the same provider.
Stop or restart it.
The Log tab shows the exception above.
It doesn't happen every time: in PyCharm 2026.1, both of my restarts showed it; in a unit test with a language server that runs in the test, one stop in four lost exit.
Cause
LanguageServerWrapper sends outgoing messages on its message writer thread (L695-L696). shutdownAll queues exit there and calls provider.stop() right after it (L2782-L2792), and SocketStreamConnectionProvider.stop() closes the socket, often before the writer has sent exit.
Fix
Before provider.stop(), wait a short time at most until the message writer has sent the queued messages. I have a fix with a test and will open a PR.
Tested with LSP4IJ main (291a09e) in PyCharm 2026.1 on Linux. 0.21.0 has no socket transport.
AI/tooling disclosure: This issue was prepared with assistance from Claude Code. I reviewed the result manually, understand the reported problem, and verified it locally.
Activity
lagergren commentedon Nov 17, 2026
Agreed this is a bug and should go in.
fix: send the exit notification before the connection of a stopped la…