This might be interesting to some of you https://clojurians.slack.com/archives/C06MAR553/p1778530093658339
Interesting. Just out of curiosity, ever discussed replacing nrepl with it in CIDER? Somehow, I have not heard of prepl.
woa. this is essentially how i use inf-clojure. not needing deps and having servers not require the main is so, so, so useful
@ag Replacing nREPL in CIDER was never discussed or considered. What was discussed in the past was to add support for the socket repl (and later on for prepl as it was more useful than the socket repl for something like CIDER). It's fairly hard to build complex functionality on top of prepl, as everything has to be done in terms of evaluating code, but it works reasonably well for the basic functionality that probably the bulk of the users rely one. Still, for something like advanced code completion you'd need to have a completion library like compliment in your deps so you can evaluate forms from it for the completion, etc.
With that change I can get a little further, but it still hangs before I can fully type a (d/entity db [:foo/id #uuid call
Hmm, I guess I'll have to keep investigating.
The fastest way for me to know what's actually stuck is a backtrace from the moment of the hang:
M-x toggle-debug-on-quit RET ;; arm C-g for a backtrace
;; trigger the hang
C-g ;; interrupts; *Backtrace* opens
The top of that backtrace tells us exactly where Emacs is getting stuck β eg. pp, accept-process-output, the EDN parser, the filter, capf, etc. Please paste the top 15-20 frames.The two ideas I think are plausible for your problem is that either the completion cache is causing the freeze or you still have the message log enabled and dumping the massive cache there is causing things to get stuck. You can try first:
(setq port-completion-use-cache nil)But the backtrace would help most.
Thanks, I appreciate your help with this. I will work on getting that backtrace tomorrow.
Great! In the mean time I've added a troubleshooting section to the README, which you might find helpful tomorrow https://github.com/clojure-emacs/port#troubleshooting
Hi Bozhidar, this seems really cool.
I have been trying to use it but it pretty frequently fully hangs Emacs to the point where I have to kill it. This happens under various circumstances. One consistent recipe to make it happen is to type (d/entity db [: in the REPL. I then cannot type anything more after that.
Any thoughts on how to troubleshoot? This is in terminal-mode emacs (`-nw`) on Mac OS.
@enn My guess is that some of the tooling Clojure code that port evals hangs in some situations, so we'll need to figure out what exactly is causing the hang. I just added a command called port-toggle-message-log that you can use to monitor what gets send by port when it hangs - this will help us a lot with debugging the problem.
Sadly, there's no way in prepl to interrupt an evaluation, so bad evals are pretty dangerous there... π
nrepl relies on a mechanism that is deprecated as well, right? or is there a newer way that will be maintained?
@dpsutton We've solved the problem permanently a while ago with a JVMTI agent https://nrepl.org/nrepl/installation.html#jvmti
It's a more complicated solution than the one that got deprecated, but it works pretty well.
https://docs.oracle.com/en/java/javase/21/docs/specs/jvmti.html#threadCategory wow. interesting! glad my knowledge was out of date
@bozhidar I tried it with the message log on, this is the last thing I see in *port-messages* . I can't copy the text because Emacs becomes unresponsive, but it looks like some kind of string out of bounds issue?
I don't think it's an issue with a bad evaluation becaause it happens before I hit enter to submit anything to the REPL.
@enn I meant "bad tooling evaluation" and your screenshot kind of confirmed this. I discovered a parsing inefficiency of large prepl responses (like this completion response from the screenshot) and I think I've managed to address it by making the parsing logic a bit smarter for such multi-chunk messages. See https://github.com/clojure-emacs/port/commit/32cc27fa6612f8bab308082b090a838488cc117c and try updating the Port to see if the fix works well for you.
Hmm, thatβs super weird. Normally you should get a backtrace at this point.
@bozhidar I tried reproing with debug-on-quit enabled, but just got pages and pages of binary out to the terminal.