-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cider Atom print-method bricking shadow-cljs UI Inspect #819
Comments
Thanks for the report! Rebinding Could you expand on why you would not want to create a simple |
(I'll look into this) |
Yes, exactly. I want the default Clojure original printing. cider installs this globally and overwrites that default though. I don't want |
Assume we fixed this. What if the user was running an older cider-nrepl? |
Note this isn't the first time shadow-cljs had to work arround cider "overreaching" with its code. I might still add that |
I'm not saying it isn't, but it's what it's been there for many years so we have to tread carefully. With a bit of luck, CIDER could only redefine these within the extent of repl evaluations, and perhaps a few other operations. Please let us know how the |
Hi @thheller I gave this task a serious shot, without luck. It's hard to change the default and then to rebind it to Basically it doesn't work (I guess the dynamic binding gets lost in some step across the stack), and I'm not sure that it's worth further investigating atm. How have you worked around this in the meantime, Shadow side? |
No, I have no intention of working arround this on the shadow-cljs side. I guess the number of people that tap a huge (circular) atom, use the Inspect UI and do so while using cider is small enough to not matter. There is also no need to change the binding in any way. I outlined how to fix it, all you need to remove is the |
Could we remove that namespace completely in lieu of nrepl pretty printing support? If a client wants stuff to be pretty printed then they can ask for it explicitly. I agree that it's really bad form to mess with |
That might be a good idea. I see it was added a long time ago to address fairly trivial things 8e79ee6
|
For extra context - this legacy namespace predates the improvements made to nREPL's printing a few years ago, so it seems like an obsolete hack. I have to admit I had totally forgotten about it. |
I was debugging a problem as shadow-cljs user reported, and while trying to debug that I noticed that the shadow-cljs UI inspect wasn't working or very sluggish, frequently running into
OutOfMemoryError
. The cause is this bit of codecider-nrepl/src/cider/nrepl/print_method.clj
Lines 37 to 40 in 247071b
The
pr-str
being the problem here.A short side note on how the problem manifests: The shadow-cljs UI Inspect lets you inspect objects of any size, so for example the full shadow-cljs runtime state, which with a build running can easily reach gigabytes when printed. It does so by using a LimitWriter, i.e. a Writer that stops after a certain amount of bytes. This is exactly to prevent large objects blowing everything up, or making everything slow, when a Human could never look at the value in full anyways.
To try you can run
shadow-cljs clj-repl
then(tap> shadow.cljs.devtools.server.runtime/instance-ref)
. With the cider-nrepl middleware installed this will be very very slow in the UI, without it is snappy. The UI is at http://localhost:9630/inspect.The fix here would be to not use
pr-str
, but rather delegate the writer to print the object into the handled stream. The macro abstracts this away unfortunately in a way that basically requires rewriting the entire macro. The gist is to call(print-method @c writer)
, i.e. the writer that gets passed to theprint-method
in the first place. It is generally not a good idea to start one print from another, as you are supposed to use the suppliedWriter
.I realize this is a bit specific to shadow-cljs and its LimitWriter, but I'd rather not do what is documented here
as that would interfere with what a cider user might prefer. I'd also rather not start being defensive in the print mechanism for Inspect by binding this var.
It would be nice if the two uses of
pr-str
in that file, get changed to properly delegate to theprint-method
with the supplied Writer, as this is globally installed and affects everything.The text was updated successfully, but these errors were encountered: