-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
When too many tasks are added synchronously to an async.queue, the queue will then process all of them in the same stack, which causes a stack overflow.
Here is a gist example.
Here is a failing test case (add this to test.test-async.js):
exports['queue big stack'] = function (test) {
var q = async.queue(function (task, callback) {
callback();
}, 1);
var i;
for (i = 0 ; i < 10000 ; i++) q.push(1);
q.drain = test.done;
};that can be fixed by replacing async.js:725:
q.process()by
async.setImmediate(q.process);(related to issue #117) But this unfortunately breaks the queue events test, as the events are then emitted in the wrong order:
AssertionError:
[ 'saturated',
'process foo',
'process bar',
'process zoo',
'foo cb',
'bar cb',
'zoo cb',
'process poo',
'empty',
'process moo',
'poo cb',
'moo cb',
'drain' ]
deepEqual
[ 'saturated',
'process foo',
'process bar',
'process zoo',
'foo cb',
'process poo',
'bar cb',
'empty',
'process moo',
'zoo cb',
'poo cb',
'moo cb',
'drain' ]
at Object.same (/root/workspace/async/node_modules/nodeunit/lib/types.js:83:39)
at Object.q.drain (/root/workspace/async/test/test-async.js:2425:14)
at next (/root/workspace/async/lib/async.js:723:31)
at Object._onImmediate (/root/workspace/async/lib/async.js:24:16)
at processImmediate [as _immediateCallback] (timers.js:330:15)
Does anyone have a real fix for this issue?
Metadata
Metadata
Assignees
Labels
No labels