For the context, I'm new to Bull (https://github.com/OptimalBits/bull) and trying to execute a lot of jobs concurrently. But Bull seems it'll wait for one job to complete.
Here is my code
const Bull = require("bull");
const jobs = new Bull('jobs');
jobs.process(async (job) => {
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
console.log(`start job.id = ${job.id}`);
await wait(3000); // Wait 3 seconds.
console.log(`end job.id = ${job.id}`);
});
void async function main () {
for (let i = 0; i < 10; i++) {
jobs.add({});
}
}();
If I ran this code, it'll take 30 seconds to execute, one job after another. What am I doing wrong and how to make this concurrent?