Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

setTimeout goes into infinite loop #8167

Closed
petkaantonov opened this issue Aug 14, 2014 · 2 comments
Closed

setTimeout goes into infinite loop #8167

petkaantonov opened this issue Aug 14, 2014 · 2 comments

Comments

@petkaantonov
Copy link

setTimeout goes into infinite loop when using floating point values for the time.

This reproduces it everytime in node 0.10.30 when the second run starts for me:

function test(r) {
    return function() {
        console.log("ran successfully", r);
    }
}

function run() {
    var r = Math.random() * 10;
    console.log("running", r);
    setTimeout(test(r), r)
}

setInterval(run, 500);

Example output before getting stuck in infinite loop:

running 2.1109230257570744
ran successfully 2.1109230257570744
running 1.4166494086384773

If integers are passed instead (eg setTimeout(test(r), r|0)) it works just fine

@spion
Copy link

spion commented Aug 14, 2014

Note that this was probably caused by #8034

briancavalier added a commit to cujojs/when that referenced this issue Aug 14, 2014
when passing decimals.  See nodejs/node-v0.x-archive#8167

Current this manifests in unit tests by locking up map-test
@misterdjules
Copy link

@petkaantonov Thank you for reporting this issue! @spion is right, it's a regression that was introduced by #8034. It's also been fixed by #8073. AFAIK, It will be included in the next 0.10.31 release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants