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

long chains of Deferred values hang #48

Open
mccraigmccraig opened this issue Aug 26, 2015 · 6 comments
Open

long chains of Deferred values hang #48

mccraigmccraig opened this issue Aug 26, 2015 · 6 comments
Labels
bug Confirmed bug

Comments

@mccraigmccraig
Copy link

i came across this while debugging another problem

(defn chain-delay-deferred
  [n t]
  (let [f (manifold.deferred/deferred)]
    (future (Thread/sleep t) (manifold.deferred/success! f 100))
    (reduce (fn [d i] (manifold.deferred/chain d (fn [v] (+ v i))))
            f
            (range 0 n))))

@(chain-delay-deferred 100 1000) ;; 5050
@(chain-delay-deferred 100000 1000) ;; hangs

there are some values of n where it hangs on some runs and returns on other runs. on my machine

@(chain-delay-deferred 4567 1000)

seems to hang about half the time

i ran this against the current tip of master 4e1fff70c5380b33e9cc2f50f03ce16af6d393b4, but i was observing the same problem against 0.1.1-alpha3

@ztellman
Copy link
Collaborator

I think this is due to stack overflows, but I'll look into it.

@mccraigmccraig
Copy link
Author

that would make sense... should an error not propagate though ?

@mccraigmccraig
Copy link
Author

tho i guess there is no way to propagate an error out if the stack has overflowed... could it log something ?

@ztellman
Copy link
Collaborator

Usually once you've overflowed, you can't reliably accomplish anything. This isn't something you should have to actively think about, though, I have a few possible workarounds that I've considered in the past.

@mccraigmccraig
Copy link
Author

on the positive side, i didn't encounter this in real-life code... i was looking for another bug and was getting behaviour which was dependent on some property of Deferreds and chain-length was one possibility i considered - then i just tried long chains to see what happened and noticed that it hung, so it's an artificial problem

@ztellman
Copy link
Collaborator

Okay, that's good to know, but I want to make sure this isn't something people need to worry about.

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