Fork me on GitHub
#nrepl
<
2021-10-18
>
bozhidar06:10:05

Wasn't the context supposed to be just the containing form or something like this? Why would someone send the entire buffer?

dominicm17:10:27

It is. But searching for matching parens so you only send the outermost form is expensive. I was trying to find an alternative that would be faster to run.

bozhidar06:10:36

Seems to me that's compliment-specific, though, as nREPL's own completion doesn't even have a notion of completion context currently.

yuhan13:10:51

How can I start an nrepl server in some main ns that catches errors in the main application thread? I'm not sure if that question makes sense, but say there's some UI or "game loop" that is continually running alongside the server, like this:

(ns my-app
  (:require [nrepl.server :as server]
            cider.nrepl))

(defonce server
  (nrepl.server/start-server
    :port 7888
    :handler (apply nrepl.server/default-handler cider.nrepl/cider-middleware)))

(defn do-thing []
  (Thread/sleep 1000)
  (println (System/currentTimeMillis))
  ;; (inc nil)
  )

(defn -main [& args]
  (loop []
    (do-thing)
    (recur)))
instead of starting the nrepl server using -m nrepl.cmdline . I can then connect to the server with Cider and interactively redefine the do-thing function, but if it throws an error (eg. uncomment the (inc nil)), the entire process exits instead of triggering the stacktrace middleware.

bozhidar05:10:11

Hmm, I never thought about this, so no answer immediately comes to mind. I assume the problem happens only for invocations that happen in -main right?

bozhidar05:10:26

Might be a good idea to post this on the issue tracker, so we won't forget about it.