The https://github.com/exoscale/cloak/ library doesn't work in babashka because it does deftype with clojure.lang.IPending (https://github.com/exoscale/cloak/blob/49c8ab0fc54725d363b6a47ac1f887deef6f55d4/src/exoscale/cloak.cljc#L8-L17), which results in the error defrecord/deftype currently only support protocol implementations, found: clojure.lang.IPending is there any easy fix for this that could be proposed to the cloak maintainers?
I suppose that could be excluded for bb
with a reader conditional
By adding a :bb () branch before the :clj? It would mean that Secret loses its derefable powers in babashka, but I guess that is an ok trade off?
In babashka.fs there are file and path . From the source code I see they correspond to java.io.File and java.nio.file.Path respectively. Sadly I'm not familiar with Java, only know nio is newer than io from some quick search. So, is path preferred than file ? Can they be used interchangeably?
Both are quite useful. For example you can't check if Path is executable
Tested it in bb, seems executable? also works for path ?
user=> (require '[babashka.fs :as fs])
nil
user=> (def p (fs/path "."))
#'user/p
user=> (fs/executable? p)
trueOh I see.. it recognize a directory as executable.
But using file is the same?
user=> (def f (fs/file "."))
#'user/f
user=> (fs/executable? f)
trueI mean Path does not have isExecutable method and I use it as an example. Some functions that expects a File might don't work properly if you give it a Path instead of File
tldr; path is to represent a destination to a file. file is to represent actual file
File and Path can be used interchangeably in babashka.fs. Path is a later introduction in the Java standard library. The vanilla Clojure standard library is designed around File when Path wasn’t around yet
@mpenet would you prefer I open a github issue on cloak?
Please use a thread when discussing the same topic
yes, an issue is fine
Hi, in a bb repl I am trying to (import java.io.Flushable) and get java.lang.Exception: Unable to resolve classname:. What am I doing wrong?
I guess this class isn't part of babashka yet. Can you provide a fuller snippet of code of what you're trying to do? I might be able to support it in the next release
We're getting ready to release v1 of the datastar SDK and I wanted to test if I could use it with bb. I use the this interface in just 1 place in the code I believe...
do you have a link to the code?
https://github.com/JeremS/datastar/blob/v1-prep/sdk/clojure/sdk/src/main/starfederation/datastar/clojure/adapter/common.clj is the file, I use the interface here https://github.com/JeremS/datastar/blob/v1-prep/sdk/clojure/sdk/src/main/starfederation/datastar/clojure/adapter/common.clj#L224
ok, this can be easily fixed in bb. but using this dep won't work right now:
com.aayushatharva.brotli4j/brotli4j {:mvn/version "1.18.0"}The actual brotli integration we provide is separate from the core SDK and the http-kit impl.
ok great. I'll add Flushable and will try the code again
With some luck that's the only java interface I use that is missing.
the next thing I''m hitting after adding Flushable is:
$ clj -M:babashka/dev -e "(require 'starfederation.datastar.clojure.api 'starfederation.datastar.clojure.adapter.http-kit)"
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: defrecord/deftype currently only support protocol implementations, found: Closeable----- Context ------------------------------------------------------------------
71:
72: ;; -----------------------------------------------------------------------------
73: ;; SSE gen
74: ;; -----------------------------------------------------------------------------
75: (deftype SSEGenerator [ch lock send! on-exception]
^--- defrecord/deftype currently only support protocol implementations, found: Closeable
76: p/SSEGenerator
77: (send-event! [this event-type data-lines opts]
78: (u/lock! lock
79: (try
80: (send! event-type data-lines opts)So I tested importing all the java apis in a bb repl and flushable seems to be the only one I miss.
I think i could get around deftype not supporting implementing java interfaces. Make it a cljc file and not include the closeable implementation in the bb case.
I'll stay alert to future bb releases and fix this. Thank you!
ok great. I added Flushable on master now. you can test this yourself with:
bash <(curl ) --dev-build --dir /tmp
when CI finishes buildingCool!
it would be cool to be able to run datastar in bb, thanks for the effort and let me know if you run into anything else
No problem. Since bb embeds http-kit you already can use datastar. It's just sending sse events with fields set a certain way. Now our SDK manages that for you so yeah it'd be nice to make it work 🙂
which os are you on? the macos aarch binary is built pretty quickly on CI
ubuntu and I confess I am lazily using bb by installing it with mise...
I'll run the script to install the fresh version later
the invocation I gave you installs it into /tmp/ so it shouldn't conflict
yeah and i can remove the one install quickly if I need to
ah the amd64 static binary just got uploaded now
(which is the one that's installed by default on linux with the script)
Ok I am gonna go eat something then I'll get to it
no hurry, enjoy
thx
When commenting this out:
#_#_Closeable
(close [this]
(p/close-sse! this))
this now loads:
/tmp/bb -e "(require 'starfederation.datastar.clojure.api 'starfederation.datastar.clojure.adapter.http-kit)"but if it runs correctly needs to be tested of course
man you never stop 🙂 I just got back!
oh I did stop for a while, I just tried ;)
That's probably the way I am gonna do it, make the file cljc then add the closable part in a clojure reader conditional. Since the rest of the api doesn't use the .close method but a close-sse! protocol fn I just need to mention not to use CloseAble to bb users...
👍
By the way I don't think I have to install bb with the script, latest version on homebrew is from 10 minutes ago...
eh... that doesn't sound right
Built from source on 2025-07-10 at 20:40:46 I don't know if your CI pipeline publishes the brew formula automatically
huh!
which tap are you using
babashka/brew would be the one I believe
built from source... never seen that before
that's what I get when doing brew info babashka
oh that's not right
I mean, that's just the released version
that one doesn't have Flushable, just try it
"built from source" is probably just the data you ran brew upgrade
oh that makes sense
so time to use the script 🙂
ok, if you run this:
bash <(curl ) --dev-build --dir /tmp
you'll get the dev build into /tmp`it works!
And the code loads. Now I'll write a little demo to make sure.
yeah. if you have tests, might be worth it to run some of them with bb too
but just a smoke test is a good start
is lazytest bb compatible? I haven't checked.
it is now :)
https://clojurians.slack.com/archives/C015AL9QYH1/p1751909572651649
well that's another thing to do I guess...
if you can put together an example, I can make a low key release to celebrate DataStar v1.0 and we can make some noise on the socials ;)
I'll keep you updated
Quick question, which version of http-kit bb is embeding?
nvm I think it is 2.8.0-RC1. So the SDK seems to work, however http-kit 2.8.0 has a bug that isn't Server Sent Events friendly.
https://github.com/babashka/babashka/blob/d6c30a6dfe003612e80782f57de5673550109ac1/project.clj#L66
oh lol I should have upgraded to 2.8.0 a long time I think
what about the bug, did you file it with httpkit?
the bug is fixed in the 2.9.x versions
Happy to upgrade to v2.9.0-beta1
I'll bump the version
Cool between this and the Flushable everything is in place for the D* SDK. 🙏
Awesome. Is there an example I can link to perhaps?
Pushed to master, let's test in 10m again
ok, re-installing the dev build should work for your OS now
Thanks I just reran the bash cmd and tried. The sse behavior is good now.
would it help if I released another bb tomorrow or no hurry?
no hurry
I'll try make the test run on bb. I don't really have examples ready for the SDK beyond some little experiments i have kept in the repo to test D* behavior. So yeah not in a hurry 🙂
@jeremys keep me posted about any release, I will give a shout out
Hi! So the SDK has it's own repo now <https://github.com/starfederation/datastar-clojure/tree/main>. One can use it via git deps, the clojars release is almost there.
Ok little demo of the D* SDK running in bb. The animation is all done on the server. The "canva" is a div of 50x50 divs sent every frame. In the video 44 frames where sent. That's quite a lot of html to morph... Gzip compression is used 519kb of html were streamed. Well I think everything works! Oh and the 2 browsers share the same state so it's mutliplayer.
Amazing!
Thanks again for your help. Right now we distribute the SDK via git deps. I am finishing the clojars release process. I think I'll release that first. When bb get's a new release I'll signal the SDK is ready for bb!
Is there a small example in the examples dir maybe where you have a similar demo?
I have not published it yet but that a port of one of the example that is already there. I made it when I was testing/integrating stream compression in the SDK. I ported it this afternoon to bb.
would it be helpful for bb users to submit this example as well to the repo? or perhaps a separate repo
I have just pushed a branch if you want to take a look at it. https://github.com/JeremS/datastar/tree/bb-support/sdk/clojure/src/bb-example
Thing is right now all the examples in the repo are more test benches I have used when developing the SDK. I might work on proper examples in a dedicated repo later. The focus right now is to finish the clojars release process and mark the SDK v1.
awesome
thanks D* allows for really cool things, I don't know if you have seen Anders demos? https://example.andersmurphy.com/
He also made the billion checkboxes demo and the billion cells one...
He is using his own backend, but the front end tool is datastar
yep. I've also met him on reClojure recently :)
cool
I got to go, thanks again for the help.
you too!
new bb is released
great! Thanks you !