Calva does not seem to kill the java processes created by running the REPL
It seems that when we stop a REPL or when we close Cursor, the java processes spawned by the REPL are not killed.
I have not tested in VSCode, but I'm assuming it happens the same thing since I had such problems when I used it just never got the time to do a better investigation of it.
Cursor Version: 1.2.1 VSCode Version: 1.99.3 Calva Version: 2.0.520
Steps to reproduce:
- Run
pgrep -l 'java|clojure'. There are no processes. - Open Cursor
- It will show one clojure process for ~/.cursor/extensions/betterthantomorrow.calva-2.0.520-universal/clojure-lsp
- Close Cursor
- Run
pgrep -l 'java|clojure'. Process is killed as expected. No processes for java or clojure. - Open Cursor again
- Start a repl (calva.jackIn command)
- Run
pgrep -l 'java|clojure'. It creates two java processes (in addition to the clojure-lsp one that is creating upon opening Cursor) - Stop the repl (calva.disconnect).
- Run
pgrep -l 'java|clojure'. The two java processes are still running. - Close Cursor (via CMD+Q, in case it matters)
- Run
pgrep -l 'java|clojure'. The clojure-lsp process was killed, but the two java processes are still there. - Open Cursor
- Run
pgrep -l 'java|clojure'. The clojure-lsp process was created again, the two java processes from before are still there. - Start a repl
- Run
pgrep -l 'java|clojure'. The two java processes from before are still there, plus we have two new ones from this new repl.
Hi! Thanks for the report.
For clarity. Calva is not supposed to kill the repl when you disconnect from it. It's not clear what you expect in that part of the repro, but anyway, you are supposed to be able to disconnect the repl and it should keep running.
Killing the editor should kill the repl, though. I know we have unsolved problems with that on Windows, and that it sometimes glitches also on Mac and Linux. But on Mac and Linux, it should most often work.
The fact that you see two java processes is probably due to how your project is set up. A default deps.edn project should only start one java process. Maybe you are using Leiningen? This could potentially be where things go wrong, but I doubt it. Calva should only care about the process it spawns and since both your java processes still run, it seems we fail at managing this process.
You could try to close Cursor without first disconnecting the repl. It was a while since I visited the code for this, but maybe we need a connected repl in order to take it down.
You can also try this repro with a more minimal project. Calva has a command fro creating a mini Clojure project. See if you can repro this with that project.
Hi!
Yep, its leiningen. The two processes isn't really a problem tbh, its more related to the amount of processes it ends up spawning.
For clarity. Calva is not supposed to kill the repl when you disconnect from it. It's not clear what you expect in that part of the repro, but anyway, you are supposed to be able to disconnect the repl and it should keep running.
This I did not know. Is there a command in Calva for actually killing the REPL? Because usually when I stop the REPL, I want to kill it; since when I use the calva.jackIn command it will create a new one, and I really only care about this new one that I'm creating.
You can also try this repro with a more minimal project. Calva has a command fro creating a mini Clojure project. See if you can repro this with that project.
Project I was using for this is actually pretty small (https://github.com/gaelrech/tapp), but it does use leiningen. But like I said, the two processes isn't really a problem, the problem is continuously spawning more
You could try to close Cursor without first disconnecting the repl. It was a while since I visited the code for this, but maybe we need a connected repl in order to take it down.
I'll try this out and reply back here later.
Thanks
Ok, so I tried closing cursor without disconnecting the REPL, but results are the same
For clarity. Calva is not supposed to kill the repl when you disconnect from it. It's not clear what you expect in that part of the repro, but anyway, you are supposed to be able to disconnect the repl and it should keep running.
Following through on this: I took a look into other commands and saw that there is the calva.jackOut; this one, indeed, seems to kill the REPL processes, so I probably should have been using this one.
So the problem here is really about when Cursor/Vscode is shutdown and there does not seem to have a hook that triggers any existing leiningen processes to be killed (clojure-lsp processes are killed correctly in such cases, for reference).
Killing the editor should kill the repl, though.
I just want to clarify here that this is specifically about when the jack-in command was used to create the repl. If the repl was started outside of VS Code (and maybe inside VS Code but manually at a Terminal - though I'm not sure about this), killing VS Code should not (and does not, for me at least), kill the repl.
I just want to clarify here that this is specifically about when the jack-in command was used to create the repl. If the repl was started outside of VS Code (and maybe inside VS Code but manually at a Terminal - though I'm not sure about this), killing VS Code should not (and does not, for me at least), kill the repl.
Yes, absolutely. It's about killing the processes spawned by Calva, not killing any REPL that might be running somewhere else.
I wonder if it could be Cursor specific or something else specific to your environment, @gaelrech. I can't reproduce it.
+1 On this, just killed like 40 instances of Java running on my Mac it has been happening more recurrently