vscode-ocaml-platform
vscode-ocaml-platform copied to clipboard
ocamllsp is never stopped, new ones started each time
I'm not sure if this might be a bug in ocaml-lsp-server or in this extension, but whenever I fire up my VScode clone (Windsurf) and edit an OCaml file, then close that file, then close the editor, I have two lingering processes. Then if I fire up VScode again, the extension launches a new language server and Merlin instance; the previous ones just hang there unused. I finally noticed the issue when the LSP's ended up eating most of my RAM (about 8GB 😱)
For example, after having run and shut down VScode twice, I have two pairs, plus even ocamlformat-rpc was left hanging the second time apparently, although that one eventually disappears on its own (after 1-2 minutes):
$ ps auxww |grep ocaml
lis 22897 0.2 0.2 321316 46536 ? Sl 22:32 0:00 ocamllsp
lis 23053 0.0 0.1 296880 27128 ? Sl 22:32 0:00 /home/lis/.opam/5.3.0+muslnative+flambda/bin/dune ocaml-merlin --no-print-directory
lis 23402 2.0 0.2 321788 46588 ? Sl 22:33 0:00 ocamllsp
lis 23406 0.4 0.1 297200 27484 ? Sl 22:33 0:00 /home/lis/.opam/5.3.0+muslnative+flambda/bin/dune ocaml-merlin --no-print-directory
lis 23429 0.2 0.1 296216 25332 ? S 22:33 0:00 /home/lis/.opam/5.3.0+muslnative+flambda/bin/ocamlformat-rpc
lis 23521 0.0 0.0 6332 2112 pts/2 S+ 22:33 0:00 grep --color ocaml
(edit) After further reading about the Language Server Protocol, it appears that clients must emit shutdown and/or exit commands to ask servers to shut down, so I guess in my setup, this OCaml extension does not emit those commands.
Okay, this is very annoying. I have done the exact same procedure multiple times and the process does not always linger. Sometimes ocamllsp disappears, sometimes they accumulate indefinitely. I have just done it 3 times and got 2 processes out of it, so it's unfortunately random. 😕
Thanks for your report @vphantom. So far I was not able to reproduce so far with the official vscode version on macos. I tried opening / closing a window with 6 projects and as many ocamllsp instances a few times and I have no leftover servers running...
Yes I started having my doubts when I noticed that sometimes I could not reproduce the issue, despite following exactly the same routine with each run (fire up the editor, choose a specific ML file, click a specific comment, close the file, then the editor). The only way I can imagine this make sense is some kind of race condition where sometimes the editor shutdown doesn't let the extension enough time to ask the language server to shut down gracefully.
Welp, I'm going to close it as "not planned, can't reproduce". I don't work with OCaml frequently right now and clearly I've been the only one reporting this, so I'll just reopen it if/when it happens again.