Fork me on GitHub
#aleph
<
2022-12-21
>
p-himik20:12:53

Just tried upgrading Aleph from 0.4.7-alpha5 to 0.6.0 (using Yada on top of it). It started giving this error:

java.lang.IllegalArgumentException: Don't know how to convert class io.netty.buffer.PooledSlicedByteBuf into class [B
	at byte_streams$convert.invokeStatic(byte_streams.clj:212)
	at byte_streams$convert.invoke(byte_streams.clj:173)
	at byte_streams$to_byte_array.invokeStatic(byte_streams.clj:797)
	at byte_streams$to_byte_array.invoke(byte_streams.clj:789)
	at byte_streams$to_byte_array.invokeStatic(byte_streams.clj:792)
	at byte_streams$to_byte_array.invoke(byte_streams.clj:789)
	at manifold.stream$map$fn__31455.invoke(stream.clj:621)
    [...]
It happens when Yada tries to convert a request's body into a byte array. Debugged for a bit, got it down to this code:
(do (require '[byte-streams.graph :as g])
    (import io.netty.buffer.PooledSlicedByteBuf)
    (require 'byte-streams)
    (require 'aleph.netty)
    (g/conversion-fn @byte-streams/conversions (g/type PooledSlicedByteBuf) (g/type (class (byte-array 0)))))
Running it on the old version gives me some conversion function. Running it on the new version gives me nil. What would be the right way to fix this?

1
p-himik20:12:52

Seems like the difference has appeared in 0.5.0-rc1.

p-himik20:12:57

Oh, crap... byte-streams is now split in two. Well that's a bloody nightmare. If I have any library that requires byte-streams, it will not be compatible with the new version of Aleph.

1
p-himik06:12:09

Thanks! Will try a bit later today.

iku00088811:06:20

Hello, sorry for the blast from the past... I googled the following and brought me here

java.lang.IllegalArgumentException: Don't know how to convert class io.netty.buffer.PooledSlicedByteBuf into class [B
                                                                                                                    at byte_streams$convert.invokeStatic (byte_streams.clj:196)
                                                                                                                    byte_streams$convert.invoke (byte_streams.clj:162)
                                                                                                                    byte_streams.graph$seq_conversion_fn$fn__27758$fn__27765.invoke (graph.clj:314)
                                                                                                                    clojure.core$map$fn__5884.invoke (core.clj:2759)
                                                                                                                    clojure.lang.LazySeq.sval (LazySeq.java:42)
                                                                                                                    clojure.lang.LazySeq.seq (LazySeq.java:51)
                                                                                                                    clojure.lang.RT.seq (RT.java:535)
                                                                                                                    clojure.core$seq__5419.invokeStatic (core.clj:139)
                                                                                                                    clojure.core$map$fn__5884.invoke (core.clj:2750)
                                                                                                                    clojure.lang.LazySeq.sval (LazySeq.java:42)
                                                                                                                    clojure.lang.LazySeq.seq (LazySeq.java:51)
                                                                                                                    clojure.lang.RT.seq (RT.java:535)
                                                                                                                    clojure.core$seq__5419.invokeStatic (core.clj:139)
                                                                                                                    clojure.core$empty_QMARK_.invokeStatic (core.clj:6195)
                                                                                                                    clojure.core$empty_QMARK_.invoke (core.clj:6195)
                                                                                                                    manifold.stream.seq.SeqSource.take (seq.clj:42)
                                                                                                                    manifold.stream.graph$sync_connect$f__2887__auto____4902.invoke (graph.clj:272)
                                                                                                                    clojure.lang.AFn.run (AFn.java:22)
                                                                                                                    io.aleph.dirigiste.Executor$3.run (Executor.java:320)
                                                                                                                    io.aleph.dirigiste.Executor$Worker$1.run (Executor.java:62)
                                                                                                                    manifold.executor$thread_factory$reify__2329$f__2330.invoke (executor.clj:70)
                                                                                                                    clojure.lang.AFn.run (AFn.java:22)
                                                                                                                    java.lang.Thread.run (Thread.java:833)
I gathered from the links the issues were resolved in latest versions, bumped libs to the following and still seem to see the error.
[yada "1.2.15"]

                 ;; 
                 [aleph "0.6.2"]
                 [org.clj-commons/byte-streams "0.3.2"]
                 [manifold "0.4.1"]
And thanks @U10EC98F5 for heroically maintaining all these libraries!

iku00088811:06:28

I downgraded the dependencies like this and the problem is gone (i.e. request body id properly consumed)

;; 
                 [aleph "0.4.7-alpha5"]#_[aleph "0.6.2"]
                 #_[org.clj-commons/byte-streams "0.3.2"]
                 [manifold "0.1.9-alpha3"]#_[manifold "0.4.1"]

Matthew Davidson (kingmob)11:06:07

byte-streams is synced with the latest Aleph, but I've been busy with adding HTTP/2 and haven't made sure the latest manifold is synced up

Matthew Davidson (kingmob)12:06:22

@U0ZS009CN BTW, do you have a minimal example I could look at, with yada in the mix?

Matthew Davidson (kingmob)12:06:47

Also, does moving yada after aleph/bs/manifold fix the issues?

iku00088819:06:56

Thanks @U10EC98F5! I did eventually figured out that yada's byte-streams was being picked up and excluding it from yada resolved the issue! https://clojurians.slack.com/archives/C0G922PCH/p1685706615663399 The project is not minimal so this is the best I can share at the moment 🙏

Matthew Davidson (kingmob)06:06:53

Unfortunately, it doesn't look like anyone's updated yada in 3 years, or I'd submit a PR

iku00088808:06:40

Yeah, reading between the lines of https://gist.github.com/malcolmsparks/bcfdcd9ae51e69aa3018c04d48f8749b it seems like there is something on the horizon :thinking_face:

iku00088808:06:58

esp. > I have since arrived at the opinion that what yada attempts is too ambitious.