Fork me on GitHub
#cider
<
2023-04-15
>
rschmukler20:04:58

Heyo! I have been having an issue that has been plaguing me for a while and I am trying to figure out how to debug it further. Occasionally when evaluating an expression that throws an exception I get an issue where my nrepl session becomes unresponsive. My JVM still works (eg. I see log messages, web server responds, etc). but nrepl related functionality (eg. documentation) doesn't work. Turning on nrepl-log-messages reveals that requests are being sent but no replies are received. The first request that doesn't get a response is as follows:

(-->
  id                                 "628"
  op                                 "analyze-last-stacktrace"
  session                            "231fae66-f907-4c94-b033-13baba6f9c96"
  time-stamp                         "2023-04-15 14:05:20.094831744"
  nrepl.middleware.print/buffer-size 4096
  nrepl.middleware.print/options     (dict ...)
  nrepl.middleware.print/print       "cider.nrepl.pprint/pprint"
  nrepl.middleware.print/quota       1048576
  nrepl.middleware.print/stream?     "1"
)
Anything that I can do to help debug this further? Unfortunately it's very inconsistent (ie. only 20% of exceptions cause this to happen, and it's inconsistent as to whether the same exception will do it... So perhaps its a race case?). As you can imagine, it's pretty disruptive to flow to have to completely restart the repl session when debugging an error.

rschmukler20:04:08

Looking at the code for: https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/stacktrace.clj#L36

(defn- handle-analyze-last-stacktrace-op
  "Handle the analyze last stacktrace op."
  [{:keys [session] :as msg}]
  (if (and session (@session #'*e))
    (analyze-last-stacktrace msg)
    (no-error msg))
  (done msg))
I'm wondering if an exception being thrown in either analyze-last-stacktrace or no-error could cause the nrepl server to become unresponsive if (done msg) is never called.

vemv08:04:34

analyze-last-stacktrace is a relatively new addition so it's possible that it has some corner case. I'd suggest creating an issue and cc/ing the author of https://github.com/clojure-emacs/haystack

rschmukler16:04:24

Thanks for the suggested, created an issue on the GitHub: https://github.com/clojure-emacs/cider-nrepl/issues/771

2