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

I guess I found one bug in async.whilst #860

Closed
rodrigorodriguescosta opened this issue Jul 22, 2015 · 1 comment
Closed

I guess I found one bug in async.whilst #860

rodrigorodriguescosta opened this issue Jul 22, 2015 · 1 comment
Labels

Comments

@rodrigorodriguescosta
Copy link

Folks, when I used the async.whilst the function where I inserted the code restarted wihout reason when I used a "loop" so long, example

   this.myfunction= function (number, callback) {
        var count=0; 
        async.whilst (
        function () {             
            return count< 5000;
        },
        function (asyncCallback) {              
                count++;
                asyncCallback();
            });

        },
        function (err) {
            callback('something');
        }
      );
    };

When I changed to async.until it worked!

@charlierudolph
Copy link
Contributor

The javascript you provided isn't valid. It also doesn't use its first parameter number.

Making some assumptions, running myfunction does error with RangeError: Maximum call stack size exceeded. However is you make the async function actually asynchronous with

function (asyncCallback) {              
  count++;
  process.nextTick(asyncCallback);
});

then it works just fine.

async.until works because the first test fails and thus it never has a chance to exceed the callstack.

This is related to #696. But it is also documented on the README

Please expand if you were running into a different problem

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

No branches or pull requests

3 participants