cider

yuhan 2024-08-28T07:33:04.523069Z

Argh.. lost a good half-hour trying to chase down a bug in all the wrong places – turns out Cider's debugger prints map entries in an extremely misleading way, making me think I had a misplaced concat somewhere

cjohansen 2024-08-28T07:34:13.446799Z

CIDER is not doing anything wrong here. You're converting the map using seq. CIDER prints exactly the data structure you asked for šŸ˜…

yuhan 2024-08-28T07:34:54.695109Z

Nope, expected output is ([:a 1] [:b 2])

daveliepmann 2024-08-28T07:35:06.166349Z

that's not what seq on a map does

cjohansen 2024-08-28T07:35:18.141739Z

Ah

cjohansen 2024-08-28T07:35:21.323169Z

Sorry šŸ˜…

daveliepmann 2024-08-28T07:37:04.868359Z

weird

yuhan 2024-08-28T07:37:07.559409Z

the inspector does this too - try cider-inspect on

(list (vec {:a 1 :b 2}))

daveliepmann 2024-08-28T07:37:54.535069Z

this smells like it could be a MapEntry thing

yuhan 2024-08-28T07:38:47.248239Z

Yeah definitely, tracking it down now

oyakushev 2024-08-28T07:39:55.195969Z

This must be related to the recent changes in internal CIDER printing logic. I will take a look

yuhan 2024-08-28T07:41:22.069619Z

Yep, the orchard.print/print multifn on :map-entry

yuhan 2024-08-28T07:47:38.497939Z

@alexyakushev I see you were the author of those changes, alright to leave the fixes to you without opening an issue?

oyakushev 2024-08-28T07:48:18.937889Z

I believe inspector was always like that. Not sure why.

oyakushev 2024-08-28T07:48:52.820169Z

An issue would still be appreciated for posterity. I'll get to the fix

šŸ‘Œ 1
yuhan 2024-08-28T07:49:11.855089Z

that's strange, surely someone else would've noticed it before

oyakushev 2024-08-28T07:51:45.988799Z

The inspector rendering code was not used in the debugger before. And in the inspector, I guess you don't often inspect sequences of mapentries.

oyakushev 2024-08-28T07:54:42.434009Z

I see, this behavior was used to print a map like a sequence of mapentries so that it looks like a regular printed map.

yuhan 2024-08-28T08:04:53.320429Z

Here's my workaround for now, until I regain my trust in the debugger actually helping me to debug things :P

(require 'orchard.print)
(remove-all-methods orchard.print/print)
(defmethod orchard.print/print :default
  [x w] (print-method x w))

oyakushev 2024-08-28T08:25:03.281819Z

This will change the look of the inspector too, but sure, whatever works

yuhan 2024-08-28T08:55:05.572799Z

Now I'm getting all sorts of TruncatingStringWriter$TotalLimitExceeded errors trying to debug a large nested value :/ I think these hardcoded values in cider-nrepl are the cause: https://github.com/clojure-emacs/cider-nrepl/blob/af0d1e0e2351293019fc95ec8b9c8822c51ac6c9/src/cider/nrepl/middleware/debug.clj#L185 I'm not so familiar with Java writers, but it appears to be throwing to signal a non-local exit instead of an unexpected error? Seems like there's a missing try-catch wrapper somewhere

yuhan 2024-08-28T08:56:23.958049Z

(binding [orchard.print/*max-total-length* 10]
  (orchard.print/print-str :longer-than-ten-chars))
;; => Execution error (TruncatingStringWriter$TotalLimitExceeded) at mx.cider.orchard.TruncatingStringWriter/write (TruncatingStringWriter.java:87).
;;    null

yuhan 2024-08-28T09:15:40.897719Z

Ah, my bad - I'm on an older version of cider-nrepl / orchard, I see it's been fixed on the current release

oyakushev 2024-08-28T10:42:17.245999Z

Fix is live in cider-nrepl 0.50.1

šŸŽ‰ 3
enn 2024-08-28T17:18:10.874399Z

I started a long-running task in a CIDER Clojure REPL which was opened using M-x cider-connect. I lost my connection to the Clojure process. I can re-connect, but the new connection has a separate output stream, so I’m not seeing the output from the earlier REPL session. Is there any way to redirect that output to the new, open REPL?

vemv 2024-08-28T17:56:26.354819Z

https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/out.clj performs bindings and alter-var-roots. Say that the 'old' code was running

(while true (println 1))
...for that case, I'd say that no matter what we do, that code will always be looking that the old binding of *out* which would point to the stale writer.

vemv 2024-08-28T17:58:25.849069Z

Probably reusing 'dead repls' (there's a defcustom for that) would result in old output and new output gathered under the same Emacs buffer, but it doesn't fix the behavior I described. I'd look instead at using file-backed logging, for example.

vemv 2024-08-28T18:06:01.755979Z

We also have cider-log-mode which certainly survives reconections :)

oyakushev 2024-08-28T19:17:57.152719Z

It's worth checking if this is related to the recent nrepl changes, just in case. Can you achieve a small reproducible that demonstrates this behavior?