Fork me on GitHub

There's a cider-connected-hook.


There's also cider-repl-init-code.


(defvar cider-repl-require-repl-utils-code
  '((clj . "(clojure.core/apply clojure.core/require clojure.main/repl-requires)")
    (cljs . "(require '[cljs.repl :refer [apropos dir doc find-doc print-doc pst source]])")))

(defcustom cider-repl-init-code (list (cdr (assoc 'clj cider-repl-require-repl-utils-code)))
  "Clojure code to evaluate when starting a REPL.
Will be evaluated with bindings for set!-able vars in place."
  :type '(list string)
  :group 'cider-repl
  :package-version '(cider . "0.21.0"))


Is there a way of adding a breakpoint that will be hit when e.g. an http request is made, i.e. when a function is called indirectly rather than directly


There should be no difference and your "breakpoint" should be triggered. That said, I often times get into a state where no breakpoints are activated for some reason - restarting the REPL typically helps.


hmm interesting. Is there more to it than doing cider-debug-defun-at-point in the function you want to debug, and then exercising the endpoint that calls the function?


I think that's it: Of course you can also use #dbg which can be convenient if you have a larger function or if you want to break only on a specific condition:


Do I need extra middleware apart from cider.nrepl/cider-middleware?


No, I don't think so.


thanks, I'll keep at it


oh, it's working


restarting the repl worked


Yeah, that's a PITA. I don't know why it sometimes happen but I hit this issue every now and then.


thanks for your help 🙂


Guess you found some weird bug - probably the state of the debugger gets corrupted by something, otherwise I can't imagine the need for a restart.


Is there a way to “debug” such debugger issues 😀?


I stopped using the debugger years ago because the debugger was so temperamental debugging http requests.


I think the debugger stops working after I quit the debugger with q after debugging an http request. I got this error: Execution error (NullPointerException) at cider.nrepl.middleware.debug/abort! (debug.clj:143), and then the debugger wouldn't start up again when debugging the same function and request.


Interesting observation - I didn't make a connection between these two things and I use q every now and then. I'll try to reproduce this in my project...


@U051H1KL1 you're right! It would be worth to report this - I'd love to see this fixed.


@U051H1KL1 IIRC now you mention it that sounds suspiciously similar to what I witnessed a few years back too — I thought I’d reported it, but it was maybe just on the slack channel and not in a ticket.


It calls Thread's .stop method which is known to cause problems - maybe that't the issue?


Maybe a workaround is to press C to skip all the breakpoints? ... Oh no, that doesn't work either - so just c?


Yeah, c works for me


Interestingly, when debugging a function that is called indirectly via http, q doesn't appear on the list of options, and when pressed breaks the debugger going forward. When debugging a function called directly, q does appear on the list of functions, and when pressed, does not break the debugger.

👍 3

Another thing that seems to mess up the debugger state is t (trace)


> Is there a way to “debug” such debugger issues


Same as with all other issues - monitoring the message exchange, instrumenting thing on the Elisp side and playing with the Clojure part of the debugger in the REPL.


If someone wants to see this fixed any time soon they'll have to look into the problem themselves. As I've mentioned a few times - effectively no one but me is working on all the CIDER/nREPL related stuff these days, which means progress is slow and painful (if any).


This is the most detailed overview of the internals of the debugger for those interested -


(it's simpler than most people would think it is)


Cool, thanks for sharing! I'll have a look next week if this is something I could do.

Eamonn Sullivan21:02:49

Am I doing something wrong here? I want to use an http mocking library in my tests, but I obviously don't need this in the production version of the library, so I added the dependency (clj-wiremock) like this:

{:paths ["src" "resources"]
 :deps {org.clojure/clojure {:mvn/version "1.10.2"}
        clj-http/clj-http {:mvn/version "3.11.0"}
        org.clojure/data.json {:mvn/version "1.0.0"}}
 {:test {:extra-paths ["test"]
         :extra-deps {org.clojure/test.check {:mvn/version "1.1.0"}
                      kelveden/clj-wiremock {:mvn/version "1.5.7"}}}
but I can't eval the buffer on a test file in CIDER (C-c C-k). It does work if I move clj-wiremock to the :deps section. Is that right, or am I just missing something silly? I might be misunderstanding what the :test alias is for...


did you add the test alias when jacking in?

Eamonn Sullivan21:02:55

Ah, do I have to do that? How do I do that?


easiest way, hit C-u before jacking in and add a -A:test right after the bin/.../clojure part

Eamonn Sullivan21:02:21

Right, thanks! I've gone this long without ever needing a test-only dependency...


no worries. if you update to the latest version of CIDER i can walk you through some dir-locals stuff to make sure you are always using the test alias so you never have to worry if you remembered to add it or not. it'll always be there when using CIDER

👀 3
Max Deineko21:02:18

Anything one should look at beside (cider-clojure-cli-global-options . "-M:test") ?


i think that's correct. there was a little bit of flux and a clojure-cli-aliases or something like that recently


still needs to be documented and its still missing a way to pass things at the end of the string to supply ports and such. ( i think)

Max Deineko21:02:09

ah, I see -- good to know!

Eamonn Sullivan21:02:12

Thanks. I probably am using the latest (I use straight.el), but other half is yelling at me to get off the computer. Will look this up... And that did work, btw. Thank you again!


I think the debugger stops working after I quit the debugger with q after debugging an http request. I got this error: Execution error (NullPointerException) at cider.nrepl.middleware.debug/abort! (debug.clj:143), and then the debugger wouldn't start up again when debugging the same function and request.