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

async.forever ... isn't ?! #437

Closed
dennyjohn opened this issue Jan 17, 2014 · 2 comments
Closed

async.forever ... isn't ?! #437

dennyjohn opened this issue Jan 17, 2014 · 2 comments

Comments

@dennyjohn
Copy link

I just did a quick test to confirm forever's behavior and it seems its not really forever !

var async = require('async');

var a = 1;

function afunc( cb ){
console.log(a++);
cb(null);
}

async.forever( afunc , function( err ){
console.log( err.msg );
} );

run it and ...

:
:
8966
8967
8968
8969
8970
8971

RangeError: Maximum call stack size exceeded

Looking at the forever function I dont see how it could ever be considered forever. I'm not good enough to fix this but if anyone did take this up, please consider adding a flag that would prevent errors from being terminal and allow continuation after calling callback.

Thanks

@rlidwka
Copy link

rlidwka commented Jan 18, 2014

I'm not good enough to fix this but if anyone did take this up

It can be fixed easily enough:

function afunc( cb ){
    console.log(a++);
    setImmediate(cb);
}

@Anachron
Copy link

But seriously, I think the function should be fixed. In a way that always refreshes the call-stack. Maybe in a doWhile(true)-loop or something like that. I mean forever is exactly like that, since it also throws errors. Another idea would be just to remove forever and use doWhile(true) instead.

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

Successfully merging a pull request may close this issue.

4 participants