I have a queue that consumes commands based on https://caolan.github.io/async/v3/docs.html#queue with an async function, because the processing requires async/await.
this.commandQueue = async.queue(async (task, callback) =>
{
await this.sleep(10); // Long running async stuff
callback(null, data);
}, 1);
The result of the task shall be sent back via 'data'.
this.commandQueue.push(
{
...command data
}, function (err, data)
{
// called when task finished - callback called
... // data is undefined
});
Issue: 'data' is undefined.
When I remove async /await from the top function section, it works, but I can't call my long-running task :-(
I have no idea how to solve this issue. Any hints?
return datafrom anasync function.