core-async

Jacob Emcken 2022-12-10T08:43:05.892069Z

After upgrading from core.async version 1.5.648 to v1.6.673 a test case suddenly triggers:

Unexpected error (NoSuchFieldError) macroexpanding async/go at (leads/message_bus_test.clj:63:7).
__thunk__0__

Full report at:
/tmp/clojure-7375904424694936670.edn
Tests failed.
I see the following in the core.async Changelog: > Perf improvements in go macro compilation But no notes about what to do for upgrading. Anyone has an idea about why?

Jacob Emcken 2022-12-10T08:47:10.715659Z

I tried reading the "Full report" but I don't understand it 😢

Jacob Emcken 2022-12-10T08:47:28.319879Z

And the full application works as expected

Jacob Emcken 2022-12-10T08:50:14.163699Z

Test case looks like the following:

(deftest message-bus-loop
  ;; Start the message bus, as needed by the dispatch handler
  (mount/start #'sut/message-bus)
  
  (let [test-out (async/chan)]
    (async/tap (:broadcast sut/message-bus) test-out)

    (testing "Received request on in channel and response on broadcast channel"
      (async/go (async/>! (:in sut/message-bus) {:event "ping"
                                                 :audit (audit/info)})) ; Line 63
      (is (= {:event "pong"}
             (async/<!! test-out))))

    )

  (mount/stop))

Ben Sless 2022-12-10T13:16:54.620119Z

Are you using lein?

Alex Miller (Clojure team) 2022-12-10T15:22:29.549369Z

This is probably an issue with aot compilation order as the ioc-macros namespace is now dynaloaded

Alex Miller (Clojure team) 2022-12-10T15:23:00.231329Z

Several other people have reported this

Alex Miller (Clojure team) 2022-12-10T15:26:49.260319Z

Adding clojure.core.async.impl.ioc-macros to the top of your aot compilation list will probably fix it if so

Jacob Emcken 2022-12-10T19:40:22.753119Z

Yes, I am using lein I didn't know I had an "aot compilation list"... but I'll look into it

Ben Sless 2022-12-10T19:53:47.143979Z

did you run lein clean after you updated the library version?

Jacob Emcken 2022-12-10T19:53:58.483209Z

yes

Jacob Emcken 2022-12-10T19:54:12.787439Z

still failing

Ben Sless 2022-12-10T19:54:55.301079Z

just making sure 🤷‍♂️

❤️ 1
Ben Sless 2022-12-10T19:56:01.135879Z

Try adding clojure.core.async.impl.ioc-macros as the first require in the namespace where the test fails?

Jacob Emcken 2022-12-10T19:58:11.339929Z

hmm still fails... like this, right?:

(ns leads.message-bus-test
  (:require [clojure.core.async.impl.ioc-macros]
            [clojure.core.async :as async]
            ...

Jacob Emcken 2022-12-10T20:30:47.699819Z

Only setting :main in a Leining project.clj causes a warning: > Warning: specified :main without including it in :aot. > Implicit AOT of :main will be removed in Leiningen 3.0.0. But including the main namespace in :aot as well, causes lein test to fail with:

Syntax error (NoSuchFieldError) compiling at ...
__thunk__0__
I've removed it from :aot for now, and "replaced it" with a comment about why. Thanks for your help ppl

Jacob Emcken 2022-12-10T20:32:22.750469Z

It also fixed the issue when I also included core async ns as Alex suggested:

:aot [clojure.core.async.impl.ioc-macros my-ns]
But I'd rather leave as much of these settings to "default" instead of pretending to know what I am doing, overwriting stuff left and right.