babashka

jeeger 2026-04-20T07:40:05.252899Z

I'm looking at babashka.http-client for extending it with support for *_proxy environment variables. I'd love to support no_proxy and both http and https proxies, but it seems like java.net.Proxy is not included in babashka/SCI(?). I guess the simplest way here would be to just use one of the variables here for a single proxy, because adding the java.net.Proxy class to babashka would have negligible benefit. Does that make sense?

jeeger 2026-04-21T13:04:45.938039Z

I'm currently working on http-client, would something like (make-proxy-selector [[<pred> <proxy-config>] [<pred> <proxy-config>]) be considered idiomatic? For pred, I'd write some combinator functions like this:

(defn proxy-scheme [scheme proxy-config]
  [(fn [^URI uri] (= (.getScheme uri) scheme)) (->Proxy proxy-config)])
(defn exclude-urls [excluded-urls]
  [(fn [^URI uri] (some (fn [excluded-url] (str/ends-with? (.getHost uri) excluded-url)))) java.net.Proxy/NO_PROXY])

borkdude 2026-04-21T13:06:31.436479Z

don't know, I'd have to look into this. how do other libs do this like hato, clj-http etc?

jeeger 2026-04-21T13:07:20.463689Z

I'll have a look, thanks for the pointers!

jeeger 2026-04-22T06:53:33.476599Z

I've opened a https://github.com/babashka/http-client/pull/81 containing my first stab at an implementation. It also contains some default proxy functionality that I haven't tested yet, I can rip that out and implement that separately.

jeeger 2026-04-22T06:55:30.143999Z

(feel free to unleash devastating feedback, this has been quite fun in itself).

borkdude 2026-04-20T07:49:20.513759Z

Can you lay out the interop that is necessary to do what you want? Then we should enable that in babashka + also adding idiomatic Clojure support to babashka.http-client

jeeger 2026-04-20T07:56:22.766699Z

I think it would just be having the java.net.Proxy class available, then I would do something like

(defn get-default-proxy []
  ...
  (proxy [ProxySelector] []
    (select [uri]
      (cond
        (= no-proxy :all) Proxy/NO_PROXY
        (contains no-proxy-list (str uri)) Proxy/NO_PROXY
        (= (.getScheme uri) "https") (Proxy. Proxy$Type/HTTP <proxy-constructed-from "https_proxy")
        (= (.getScheme uri) "http") (Proxy. ...))))))
Just for the default proxy behavior implementation, this is probably what it'd look like.

borkdude 2026-04-20T07:56:54.860559Z

so you also need ProxySelector then right

jeeger 2026-04-20T07:57:03.243459Z

That's already in

borkdude 2026-04-20T07:57:13.674529Z

then it makes even more sense to just add http://java.net.Proxy

👍 1
jeeger 2026-04-20T07:58:34.757149Z

I'll look into building a person bb that has the classes, I remember seeing some documentation for that.

borkdude 2026-04-20T07:59:29.866639Z

the class can be added to src/babashka/impl/classes.clj but we need some interop tests around this in babashka.interop-test to be tested with the native. just writing a Github issue is ok too

borkdude 2026-04-20T07:59:52.260089Z

probably you will have to add Proxy$Type separately too

👍 1
jeeger 2026-04-20T09:18:17.080909Z

Huh, I'm tryng to build babashka from source, but the uberjar script gets to the reflection step (`lein with-profiles …,+reflection do run` ) and just hangs. Strange.

borkdude 2026-04-20T09:18:47.190769Z

did you clone the submodules too? this is a common mistake people forget

jeeger 2026-04-20T09:20:51.093529Z

yep, forgot it before, did it correctly, but it still hangs. Strange.

borkdude 2026-04-20T09:21:13.674729Z

are you running with a graalvm jvm?

jeeger 2026-04-20T09:22:24.277159Z

Huh, now it seems to work. Great.

jeeger 2026-04-20T09:23:52.638459Z

Thanks for the help nonetheless!

borkdude 2026-04-20T09:24:37.611489Z

ok :)

jeeger 2026-04-20T10:20:12.521939Z

There's a https://github.com/babashka/babashka/pull/1970, I hope this is somewhat useful.

borkdude 2026-04-20T10:20:56.244949Z

looks good!

jeeger 2026-04-20T12:26:47.700869Z

Awesome! I'll write some code for http-client later this week.

borkdude 2026-04-20T12:27:25.963429Z

great, thanks

jeeger 2026-06-05T09:43:33.187409Z

Hey, is there still something missing in the http-client PR for more complicated proxy routing?

borkdude 2026-06-05T09:44:41.895849Z

I hope to look at this soon again. currently focusing on different parts of bb libs :) Also, not high priority since we can do it using Java interop already, right?

jeeger 2026-06-05T09:45:35.231189Z

No problem! Yeah, I think so re. Java interop, but I also have the "default proxy" functionality in the pipe somewhere.

borkdude 2026-06-05T09:46:01.169819Z

👍 let me make a note to look at this before I publish a new bb

👍 1
borkdude 2026-06-05T09:46:18.654239Z

currently I'm knee-deep in bb.cli new features

borkdude 2026-04-20T13:52:09.901869Z

new rlz! https://clojurians.slack.com/archives/C06MAR553/p1776692645742509

🎉 4
jeeger 2026-04-21T13:05:26.028019Z

oh no, even includes my spelling mistakes 😛

borkdude 2026-04-21T13:06:10.054759Z

I thought I fixed those? ;)

jeeger 2026-04-21T13:07:05.744099Z

Ah, it's only in this message. Thanks for the spelling correction.

2026-04-20T17:19:25.226489Z

Hi, is it possible that java.util.concurrent.locks.ReentrantLock used to be part of the classes usable from babashka and were removed? I am running some code I haven't run in a while and I am having trouble with that class (`Unable to resolve classname` error).

✅ 1
borkdude 2026-04-20T17:27:32.887469Z

$ bb -e 'java.util.concurrent.locks.ReentrantLock'
java.util.concurrent.locks.ReentrantLock

borkdude 2026-04-20T17:27:38.720009Z

still part of bb

2026-04-20T17:28:28.641769Z

I must be doing something wrong then. Thanks!

borkdude 2026-04-20T17:28:36.402389Z

check the version of your bb

2026-04-20T17:28:57.001089Z

babashka v1.12.199

borkdude 2026-04-20T17:29:13.204119Z

that's old

2026-04-20T17:29:46.952439Z

that's what homebrew on linux got me...

borkdude 2026-04-20T17:30:41.332999Z

maybe update your homebrew repo

borkdude 2026-04-20T17:31:29.737219Z

ReentrantLock was added in .200

2026-04-20T17:32:15.952669Z

ok thx I really must have messed up something with homebrew.

2026-04-20T17:34:21.834689Z

my bad I am an idiot... I have mise messing things up... bb must be installed twice I updating the brew won't fix my issue.

borkdude 2026-04-20T17:34:44.673489Z

no problem

2026-04-20T17:34:57.702079Z

Thanks again.

2026-04-20T17:36:45.058969Z

its fixed!

🎉 1
mauricio.szabo 2026-04-20T18:06:39.047129Z

Hi, a question about the nREPL implementation of Babashka. I am doing something... weird (like always hehehe) and I would like to share if it's the "right way" of doing that (whatever that might mean in the context) Basically, I am running Babashka's nREPL manually - it's a .bb file that runs nrepl/start-server!. This is used to spin up docker, manually, and then tail for logs; I'm using babashka.process to tail for the logs, and then capture the stdout and stderr into a string and printing it. Because these things run in parallel, I am having some situations where the bencode from nREPL is getting interleaved - essentially, supposing a code I do returns :ok, and it prints on the screen hello. This in nREPL would be an {"out" "hello"} message (`d3:out5:helloe` in bencode) and a eval result {"value" ":ok"} message (`d5:value3::oke` in bencode). In this specific case, I am getting something like dd3:5:valueout.... Now, what should the "right way" of doing this in a way that doesn't interfere with nREPL? The code of what I am doing right now is this one: https://gitlab.com/mauricioszabo/see-ya/-/blob/rewrite-without-vibe-coding/src/see_ya/executor.clj?ref_type=heads#L57-88, nothing too crazy here, except that I do a (.flush io) (which I believe is where it causes the problem, but it helps a lot with the output because I have multiple cases where the output is never printed until the command exists, which sometimes do take a while).

borkdude 2026-04-20T18:13:22.529049Z

Let me see if I understand the problem... the bencode from nREPL is interleaved?

borkdude 2026-04-20T18:13:41.863039Z

oh I see

borkdude 2026-04-20T18:13:50.791569Z

I think the bencode writer should be serialized using locking or so

borkdude 2026-04-20T18:13:59.080289Z

such that they can't be interleaved

borkdude 2026-04-20T18:16:43.152119Z

let me push a fix so you can use the development version

mauricio.szabo 2026-04-20T18:21:33.571379Z

Amazing, thanks 🙂. I'll check it as soon as you push the fix (hopefully I can also reproduce the problem, it's hard to reliably reproduce it...)

borkdude 2026-04-20T18:58:21.276579Z

pushed fix. wait for 10 mins and then install the dev build with:

bash <(curl )  --dev-build --dir /tmp

👍 1
mauricio.szabo 2026-04-22T17:11:06.108349Z

Just a heads up... I am still looking at this error. Because the interleave happens with async code, it's hard to reliably reproduce... and suddenly, I can't anymore facepalm. So I'm starting to implement a part of the code that's completely parallel, to check if I can reproduce the error again, and as soon as I can I'll test with this dev build 🙂

borkdude 2026-04-22T17:17:55.251229Z

I have a test which reproduces this

mauricio.szabo 2026-04-23T03:33:38.953569Z

And it works, thanks! The error I was experiencing on my side is also fixed 👍

🎉 1