question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How add async functions to queue?

See original GitHub issue

I am trying to add an async function to the queue. While the function is executed, the task appears to stay in the queue. e.g. the queue length remains at 1.

Here is some example code:

const Queue = require('queue');
const queue = new Queue({ autostart: true });

async function output() {
    console.log('hi');
}

queue.push(async (cb) => {
    await output();
    cb();
});

What am I missing?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jessetanecommented, Apr 26, 2021

ah makes sense, your example didn’t show any concurrency limit so i assumed you wanted parallel execution (which is what Promise.all is good at)

0reactions
ErikKalkokencommented, Apr 26, 2021

My use case is that I have a task that must only have one instance running at a time. I am using a queue with concurrency = 1 to ensure that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JS async / await tasks queue - javascript - Stack Overflow
A queue helps us to straighten tasks in an async environment into a sync pattern. That is exactly what we want. ➜ "Run...
Read more >
Node.js async.queue() Method - GeeksforGeeks
The async module is is designed for working with asynchronous JavaScript in NodeJS. The async.queue returns a queue object which is capable ...
Read more >
async.queue() Method in Node.js - Tutorialspoint
The async module provides different functionalities to work with asynchronous JavaScript in a nodejs application. The async.queue() method ...
Read more >
Implementing an async queue in 23 lines of code
A task will be a function that if called returns a promise. · The queue accepts an array of tasks and the maximum...
Read more >
async-await-queue - npm
Start using async-await-queue in your project by running `npm i ... There are 15 other projects in the npm registry using async-await-queue.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found