Fork me on GitHub
#core-async
<
2017-11-17
>
fossifoo13:11:10

what is the idiomatic way to zip two channels? my google foo failed me so far 😕

tbaldridge13:11:00

(async/map vector [ch1 ch2 ch3 ch4])

fossifoo13:11:22

thanks. that was um, much simpler than i imagined

fossifoo13:11:41

too much rxjava for me i guess 😉

tony.kay16:11:33

I’ve had two different people report to me that core.async doesn’t work correctly (see Wilker’s comment just above about losing a message) if asserts are elided in cljs advanced compilation. Just putting that out there in case others want to chime in.

ajs17:11:02

@tony.kay that's a bit concerning. Eliding asserts is a default in many popular lein profiles, I wonder why that would break a core library

tony.kay17:11:30

not sure, but I’ve had two users of Fulcro report that the core async queues “lose messages” if elide asserts is true when using advanced optimizations. One of them is trying to build a minimal case. It might be relatively easy to spot in the source. I mean: it has to be a spot where the value of the assert or a side-effect accidentally embedded within it is (accidentally) important.

hiredman18:11:31

searching fulcro using the github ui for 'async' that is in there, also lots of go loops created just to publish a single message (async/go (>! ch something))

ajs18:11:12

I thought a key design goal of Om Next was to avoid use of core.async? According to a @dnolen talk

ajs18:11:17

Does fulcro use core.async a lot as a requirement?

ajs18:11:34

There are several test files in core.async's source, I wonder if they have ever run under cljs with assets elided

hiredman18:11:47

you have leaped over the most obvious conclusion

hiredman18:11:25

if fulcro users are reporting dropped messages, then the place to start looking for bugs is fulcro

tony.kay19:11:12

@ajs @hiredman The front-end does eliminate the need for async. Om Next’s design is to isolate async, not eliminate it.

tony.kay19:11:27

you’re in an async execution environment…

tony.kay19:11:45

So, there are not “a lot of go loops”. There are exactly two channels for each network handler…usually just one networking. One is for sending the requests (a queue), and the other is to provide blocking so that only one goes at a time. Simple as that.

tony.kay19:11:49

There’s about 12 lines of core async in the entire library isolated to the depths of the plumbing

wilkerlucio19:11:40

about the elide assets, it doesn't need to be advanced compilation, just adding the elision is enough to trigger the problem

tony.kay19:11:53

and there are no asserts in that code in Fulcro

tony.kay19:11:09

which has been working fine in production apps for a couple of years

hiredman19:11:22

the line I linked to is an assert around an offer

tony.kay19:11:46

(slaps forehead)

tony.kay19:11:12

Forgive my blindness….the snake just bit me

dnolen19:11:22

Alex Miller just cut core.async 0.3.465, this includes @juhoteperi macro enhancement

dnolen19:11:30

should be less cumbersome to use now - please give it a spin

ajs20:11:36

@tony.kay does that (async/offer! queue e) need to run, because if so it will obviously not run if asserts are elided

tony.kay20:11:43

@ajs it is obviously the problem…I just didn’t see it. I had a team of people working on this part of the lib early on. Embedding logic in an assert is something I know better than to do, and I assumed I wrote that code…so, I was assuming it couldn’t have asserts. My bad

tony.kay20:11:19

I guess it is even possible I did write it, and was not having a good day 😜

tony.kay20:11:30

but I darn well know not to do it

ajs20:11:33

no problem with having a bad day. i have quite a few of those

ajs20:11:37

@tony.kay for what it's worth, i assert things using this, because if elided the value is passed through (and it allows me to litter my code with type assumptions without having to bind to let first, keeps the code succinct) : https://github.com/astoeckley/clojure-assistant/blob/master/src/assistant/asserts.cljc#L50

tony.kay20:11:50

Yeah, I actually lean the other way and like that assert drops the processing altogether (in case it is high-overhead assertion, like a spec check)

ajs20:11:49

i this case i'm wrapping things that need to be there anyway, but allowing tests with predicates in case asserts are turned on

tony.kay20:11:51

that is handy

ajs20:11:29

it's one of the ways i avoid shooting myself in the foot with a language that has no type checking, but without adding all the code necessary in typed-checked languages (or the verbosity of clojure.spec)

tony.kay21:11:41

@hiredman Thanks for digging into that. Even though it was a little embarrassing, I appreciate that you took the time to look at the code.