how to make async work with async/await
See original GitHub issuevar async = require('async');
var workPool = async.queue(async (task, taskComplete)=>{
console.log(1, taskComplete);
async.retry(3, async (retryComplete)=>{
console.log(2, retryComplete);
// retryComplete(null, task);
});
});
workPool.push("test");
I wonder why i got this result:
$ node test.js
1 undefined
2 undefined
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
async function - JavaScript - MDN Web Docs - Mozilla
Async functions can contain zero or more await expressions. Await expressions make promise-returning functions behave as though they're ...
Read more >Async/await - The Modern JavaScript Tutorial
The async keyword before a function has two effects: ... The await keyword before a promise makes JavaScript wait until that promise settles,...
Read more >Async and Await | The Odin Project
await is pretty simple: it tells JavaScript to wait for an asynchronous action to finish before continuing the function. It's like a 'pause...
Read more >Asynchronous Programming with Async and Await - Visual Basic
A synchronous method returns when its work is complete (step 5), but an async method returns a task value when its work is...
Read more >using async await and .then together - Stack Overflow
I always use async/await and .catch() instead of using async/await and try/catch to make code compactly. async function asyncTask() { throw ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@pawelotto I think for that you can use node promisify util, I didn’t test but since the main callback function signature is compatible I assume it will work.
So the example above will become (without handling error):
Maybe you can try neo-async