Fork me on GitHub
#core-async
<
2022-12-10
>
Jacob Emcken08:12:05

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 Emcken08:12:10

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

Jacob Emcken08:12:28

And the full application works as expected

Jacob Emcken08:12:14

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 Sless13:12:54

Are you using lein?

Alex Miller (Clojure team)15:12:29

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

Alex Miller (Clojure team)15:12:00

Several other people have reported this

Alex Miller (Clojure team)15:12:49

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

Jacob Emcken19:12:22

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

Ben Sless19:12:47

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

Ben Sless19:12:55

just making sure :man-shrugging:

❤️ 1
Ben Sless19:12:01

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

Jacob Emcken19:12:11

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

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

Jacob Emcken20:12:47

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 Emcken20:12:22

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.