Skip to content

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

Open
@korvus81

Description

@korvus81

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions