Fork me on GitHub
#cider
<
2021-11-29
>
paulspencerwilliams11:11:51

So, I’ve been successfully using cider-debug-defun-at-point to allow me to debug functions. However, I’ve been trying to set breakpoints at certain locations within a function to allow me to skip noisy sections. This works fine in a toy project.

(ns test-dbg.core)

(defn foo
  "I don't do a whole lot."
  [x]
  #dbg (println x "Hello, World!"))

(foo 3)
But doesn’t work in my work project when debugging a http request.
(defn- return-something
  [dep1 blah
  #dbg
  (when blah 
The function evaluates successfully but the breakpoint doesn’t invoke the debugger. I’ve tried #break too? What am I doing wrong?

Sophie12:11:51

The function is not called from the repl, right? I had the same problem and my guess is that cider does not get an answer from the repl for asynchronous function calls and thus does not know of the execution of the function. But that's just a guess as I didn't have the time to look into the implementation yet.

bozhidar12:11:31

Yeah, I recall there was some sporadic issue with async evals, but I think it was fixed a while ago.

Sophie12:11:41

Tip: execute the function you want to debug manually or from a test.

paulspencerwilliams12:11:23

@U02MWDCU3U6 before the function evals from a http request or instead of?

Sophie12:11:37

I do it instead of

👍 1
bozhidar12:11:37

Did you start the project from the same REPL you've connected CIDER to?

paulspencerwilliams12:11:05

Yeah, same REPL :thumbsup:

bozhidar12:11:53

That's pretty much the only thing you need to do for this to work.

paulspencerwilliams15:11:03

So, after further investigation, I can now use #dbg in a function that I eval using C-x C-e . However, this does not work if I eval the function using C-c C-k which is what I was doing prior.

dpsutton15:11:09

are you saving the buffer?

dpsutton15:11:34

which functions do these key chords invoke? I’m assuming eval last expression and load-buffer?