-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
Returning a java.net.URL or java.net.URI at the REPL causes CIDER to try to connect #2825
Comments
@dgr you're perfectly right to be confused. This is part of a feature to display images in the repl buffer. However it has knock on effects of connecting to every URL or URI that's returned to the repl which is quite dangerous in my opinion. Try the following emacs lisp to disable it:
|
Thanks for the reply. I'll disable that. Yea, if you were developing an API, an unexpected connection to your running system could delete something in your database, all because you were fiddling around with the code to create appropriate URIs. Displaying images seems like a generally bad trade. Or maybe it's just bad to set the defaults that way; maybe reverse them, so that you have to purposefully enable this functionality. |
Yeah, I'll likely disable this in future CIDER release. Still, I don't think the feature is that problematic. @Cartmanishere recently fixed a couple of similar problems there, I hope he'll has the time to look into this one as well. |
FYI - I've disabled |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
Upon quick inspection, these seem to be the offending lines: The image handling appears to be separate, which is cool. Getting rid of those lines would break things like I'd be up for playing around with this, but I don't know how to run CIDER with changed nrepl middleware. Is there a hacking guide somewhere? As ever, thanks to all for time and consideration and efforts on these projects we love and use and love to use. PS. I landed here from this part of the docs which had a link: https://docs.cider.mx/cider/repl/configuration.html#displaying-images-in-the-repl |
Outstanding! --- Thank you. |
Looked at this a bit more this afternoon. It's all very clever, and I learned a lot and has some laughs, so thanks as ever for that. The URI/URL behavior is actually kinda cute because it allows an expression like But, of course, it does that by fetching the contents - which we've all found surprising in other contexts (http APIs and pages for instance). What I aimed to accomplish was to eliminate the surprising bit, but preserve the fun of printing images. I've got this in my config now: (setq cider-repl-use-content-types t)
(defun rewrite-content-type-list ()
(setq cider-repl-content-type-handler-alist
(seq-filter (lambda (item) (not (string= (car item)
"message/external-body")))
cider-repl-content-type-handler-alist)))
(add-hook 'cider-repl-mode-hook #'rewrite-content-type-list) It works by disabling the There are lots of other potential fixes (and improvements to the related 'content-type' and 'slurp' nrepl middleware), but getting a nice middleground behavior by just configuring cider from the outside feels ok for now. 🙇♂️ - respect to all involved, as ever. [@cnuernber - mildly relevant to your interests] |
Thanks for looking into this! I guess we can extend the docs a bit to cover your findings. |
Btw, I don't think you actually need the hook function - you could have just modified |
Sure. Or this issue on its own may help someone down the line.
I thought so too, but I got a message at startup about |
I'm using the latest CIDER snapshot as of March 25, 2020, and when I create a URI or URL at the CIDER REPL, it prints the representation of the returned object (e.g.
#object[java.net.URI ...]
) but then it tries to connect to the URI/URL. If the URI/URL can be connected to, this will return, for instance, an HTML document. If not, it will throw an error.I would not expect this behavior since returning a URI or URL from a function would be a very normal thing to do in the case of REPL-driven development. If I wanted to connect to the URI/URL, I would expect to use cli-http or something like that.
EXAMPLE:
The text was updated successfully, but these errors were encountered: