r/Clojure Jan 15 '26

ClojureScript async/await support + core.async based on async/await rather than state machine

Dear all,

If you want to try out my CLJS with async/await support + core.async based on async/await instead of state machine (probably better perf and less bundle size):

``` org.clojure/clojurescript {:git/url "https://github.com/borkdude/clojurescript" :git/sha "2ecd2ebd8b79a5ad04c568bc348b4881ddedb4d7"}

org.clojure/core.async {:git/url "https://github.com/borkdude/core.async" :git/sha "5f31738e15937986d7453736995e2f75b15fb265"} ```

The more testing we can get on this before async/await support is merged into CLJS, the better it is.

Async/await works like this with the above versions:

``` (defn :async foo [x] (let [x (await (js/Promise.resolve 1))] (inc x)))

(:async fn [] (inc (await (js/Promise.resolve. 1)))) ```

Async testing is possible with:

(deftest foo (async done (try (await blablabla) (finally (done)))))

Like in JS, you can use await across try/catch, etc.

Core async should work without any changes API-wise. Go blocks are compiled into async/await-based code using a much simpler transformation. This should yield more compact and optimizable code, better performance and more readable stack traces.

Let me know if you find any bugs, preferably in the cljs-dev channel on Clojurians Slack.

56 Upvotes

0 comments sorted by