You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And for failed DB operations, I've created a function to assign them to a queue, each failed job has a unique queue name and different processor (update, create, delete, ...etc):
// this is factory bullmq function that job is to create unique queue, unique worker with a specific processor
export async function failedBullMQ<T>(uniqueQueueName: `Failed-${string}`, data: T, processor: (...args: T[]) => Promise<any>) {
console.log("failedBullMQ");
const { queue } = await bullmq(uniqueQueueName, processor);
await queue.add("retry-jobs", data, { repeat: { every: 2 * 60000 }, jobId: `${uniqueQueueName.split("-")[1].concat(new Date().toDateString())}` });
}
but I'm facing a bug with this function, which its worker doesn't run, I'm testing it like below:
export async function updateUserDataController(data: any) {
try {
// processing the data
// await updateQuery(processedData);
throw new Error();
} catch (error) {
// move the data to the failed queue
await failedBullMQ("Failed-UpdateUserData", data, updateUserDataController );
console.log("something went wrong. the data are moved to the queue.")
}
}
what is actually happening when I start running the code is:
1- console.log("failedBullMQ"); printed in the console
2- worker.on("ready", () => console.log(worker for ${queueName} is ready...)); printed in the console
3- I can see all bullmq related data for the job in Redis And that's all, nothing else, even the options { repeat: { every: 2 * 60000 } and attempts: 10, backoff: { type: "fixed", delay: 3500 } } don't work either.
P.S.: I'm using the setup in bullmq.ts for creating a single queue and it has the exact same options but it has nothing to do with the failedBullMQ function. it had been tested many times, and it worked. I can't figure out where the bug is by myself. I'd be grateful for your help.
UPDATE:
The reason behind the worker doesn't get active turns out to be because I'm actually throwing an error after calling failedBullMQ inside the catch block using a custom error class -not shown in the pasted code for reproduction purposes- which makes the app crash. However, the repeat problem is continues and still can't manage to make the process repeatable
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have these configs inside
bullmq.ts
:And for failed DB operations, I've created a function to assign them to a queue, each failed job has a unique queue name and different processor (update, create, delete, ...etc):
but I'm facing a bug with this function, which its worker doesn't run, I'm testing it like below:
what is actually happening when I start running the code is:
1-
console.log("failedBullMQ");
printed in the console2-
worker.on("ready", () => console.log(worker for ${queueName} is ready...));
printed in the console3- I can see all bullmq related data for the job in Redis And that's all, nothing else, even the options
{ repeat: { every: 2 * 60000 }
andattempts: 10, backoff: { type: "fixed", delay: 3500 } }
don't work either.P.S.: I'm using the setup in bullmq.ts for creating a single queue and it has the exact same options but it has nothing to do with the
failedBullMQ
function. it had been tested many times, and it worked. I can't figure out where the bug is by myself. I'd be grateful for your help.UPDATE:
The reason behind the worker doesn't get active turns out to be because I'm actually throwing an error after calling
failedBullMQ
inside thecatch
block using a custom error class -not shown in the pasted code for reproduction purposes- which makes the app crash. However, the repeat problem is continues and still can't manage to make the process repeatableBeta Was this translation helpful? Give feedback.
All reactions