Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deferred/chain only works for very few parameters....in a core.async go block #52

Open
korvus81 opened this issue Sep 24, 2015 · 1 comment
Labels
bug Confirmed bug

Comments

@korvus81
Copy link

This might be related to #48, but I'm not sure. I was running into a problem where my code kept hitting an OutOfMemory error when it was compiling with `lein run`` (in my IDE, I instead got an error about clojure.core/long not being found...I think there's a subtle difference in how they build). I eventually tracked it down to the length of a (d/chain ...) call inside a core.async go block. So I'm guessing this has to do with the interaction of multiple macros...

I was able to demonstrate it in the repl on manifold 0.1.1-alpha4 (Clojure 1.7.0 and Java 1.8.0_60-b27) by tweaking the example from https://github.com/ztellman/manifold/blob/master/docs/deferred.md#composing-with-deferreds

clj.core=> (def d (d/deferred))
#'clj.core/d
clj.core=> (d/chain d inc inc inc inc inc inc #(println "x + 3 =" %))
<< … >>
clj.core=> (d/success! d 0)
x + 3 = 6
true

That works with even a long chain of functions (hence why I added inc's).

clj.core=> (def d (d/deferred))
#'clj.core/d
clj.core=> (go (d/chain d inc inc inc inc inc inc #(println "x + 3 =" %)))

ExceptionInfo Class not found: clojure.core/long  clojure.core/ex-info (core.clj:4593)
clj.core=> (go (d/chain d inc inc inc inc inc #(println "x + 3 =" %)))

ExceptionInfo Class not found: clojure.core/long  clojure.core/ex-info (core.clj:4593)
clj.core=> (go (d/chain d inc inc inc inc #(println "x + 3 =" %)))

ExceptionInfo Class not found: clojure.core/long  clojure.core/ex-info (core.clj:4593)
clj.core=> (go (d/chain d inc inc inc #(println "x + 3 =" %)))

ExceptionInfo Class not found: clojure.core/long  clojure.core/ex-info (core.clj:4593)
clj.core=> (go (d/chain d inc inc #(println "x + 3 =" %)))

ExceptionInfo Class not found: clojure.core/long  clojure.core/ex-info (core.clj:4593)
clj.core=> (go (d/chain d inc #(println "x + 3 =" %)))
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x7f78eaab "clojure.core.async.impl.channels.ManyToManyChannel@7f78eaab"]
clj.core=> (d/success! d 0)
x + 3 = 1
true

In this case, it works for three parameters to d/chain and no more.

Unfortunately, I'm fairly new to Clojure, so debugging this is probably beyond my ability. But, I did see that three arguments is the breakpoint for some code in that function, so that's probably a clue...
https://github.com/ztellman/manifold/blob/master/src/manifold/deferred.clj#L922-L925

I'm probably about to write the world's dumbest implementation of d/chain to fix this for my case, but it would be great if we could figure out if this is a core.async issue or a manifold issue and find a way to fix it...

@ztellman
Copy link
Collaborator

If you use apply it won't try to unroll the body, that should be an okay workaround until I figure out what's going on here.

@ztellman ztellman added documentation bug Confirmed bug and removed documentation labels Jan 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants