-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
'Maximum call stack size exceeded' using async.forEachLimit #75
Comments
should be moved in front of the iterator call. Note: You will only encounter this bug if code inside iterator iterator calls the callback in the same tick. |
STOP calling SYNC functions in async.js |
I encountered this problem when I had a conditional If you really think you should, you can work around this by using |
@jacobrask That worked well. Thanks |
Doing |
Saying "stop calling sync functions in async" is missing the point - it's broken, and it's only in forEachLimit that this appears to be an issue.
While I can fairly easy protect against that very specific example (as @jacobrask mentions by filtering), what if doStuff() (which might be in a library outside my control) decides to call my callback without a process.nextTick()? |
I've added some code to call async.nextTick if it detects a synchronous iterator which should avoid a stack overflow in these cases. But seriously, STOP CALLING SYNC FUNCTIONS IN ASYNC! ...make your functions consistently synchronous or consistently asynchronous instead ;) |
This also happened for me with |
Sometimes the preprocessors and compilers call their callback synchronously. In those cases, async.eachSeries will recurse synchronously, and the call stack will grow very large. Also see caolan/async#75 (comment) and caolan/async#173 (comment). Incidentally, this cuts initial build time in half.
Also happen in |
Happen with me on |
Facing same issue with |
async.queue, too, of course. |
I was doing a sync operation. I fixed it by changing from: callback(); to setTimeout(callback, 0); |
This happened to me when I had a catch attached to a promise. Something like: catch must be thrown before async bit in promise, because this error thrown only when exception occured in promise. ` |
I understand that we should stop calling sync functions in async. But, if calling the sync function callback() inside the async body is wrong, why does the async documentation show that in the examples? Can someone help me understand what is the 'proper' way to work with the async module instead? Here's an example directly from the async documentation:
https://caolan.github.io/async/docs.html#each Thanks! |
* Error fault with `RangeError: Maximum call stack size exceeded` * using `process.nextTick` * suggested option of `setTimeout(callback, 0)` but not viable for CONTRIBUTING.md See caolan/async#75
Log
The text was updated successfully, but these errors were encountered: