Closed hieuit7 closed 7 years ago
Sounds like you have an issue with multiple callbacks:
parse(task).then(() => {
debug('------>>>> Done task: ');
callback();
}).catch((e) => {
debug('---Have error task!!', e);
callback();
});
This code is vulnerable to multiple callbacks if an error is thrown later on in the callback()
chain. You can asyncify
the parse
function -- that will protect against this:
async.asyncify(parse)(task, (err) => {
if(err) {
debug('---Have error task!!', e);
return callback();
}
debug('------>>>> Done task: ');
callback();
});
or just:
let queue = async.queue(async.asyncify(parse), 100)
I use Promise for parse function. Only then or catch error occur.
On log debug, haven't debug error through out!
@hieuit7 if it's a promise then you can call the callback after the promise chain. at the moment, if it's inside the promise chain and it throws, then it will get caught by the catch. Try using finally.
parse(task).then(() => {
debug('------>>>> Done task: ');
}).catch((e) => {
debug('---Have error task!!', e);
})
.finally(callback);
I'm sorry, this is my wrong.
The parse function has been return without resolve or reject call back by logic bussiness. I will close this thread. Thank you for help!
I use async version 2.4.0:
I have a issues with push 1000 task to queue concurency 100,
here this is code:
and debug is:
consumerGroup is kafka-node module, this is module working with kafka, and message event received is a block messages.
The queue length is big and not execute. Please help me debug this.