Closed datnqvn closed 1 month ago
Can you post your code? In addition to the test suite, there is also an example script in the repo for scheduling: https://github.com/timgit/pg-boss/blob/master/examples/schedule.js
Hi @timgit , Here is my code, it's very simple, just follow the example in your documentation `if (!boss) { boss = new PgBoss({ host: process.env.DATABASE_HOST, database: process.env.DATABASE_NAME, user: process.env.DATABASE_USERNAME, password: process.env.DATABASE_PASSWORD, });
try {
await boss.start();
// const queueNames = Object.values(QUEUE_NAMES);
// for (const queueName of queueNames) {
// await boss.createQueue(queueName);
// }
const queue = 'readme-queue';
await boss.createQueue(queue);
await boss.work(queue, async ([ job ]) => {
console.log(`received job ${job.id} with data ${JSON.stringify(job.data)}`)
});
const id = await boss.send(queue, { arg1: 'read me' });
await boss.schedule(queue, `* * * * *`,{ arg1: 'read me' });
} catch (err) {
}
}`
and here is the result in the jobs table
I'm not sure why your jobs are all failing (state=failed in your screenshot). Run the schedule.js example script in an empty db. It should produce the following output.
$ node examples/schedule.js
received job 3c9a4041-916d-4581-b357-690959b1d084 with data {"arg1":"schedule me"} on 2024-10-05T16:04:21.025Z
received job 90c3ae11-56d0-4449-87f6-05e5e49e2b6c with data {"arg1":"schedule me"} on 2024-10-05T16:06:49.127Z
All of the jobs should be state=completed:
Hi @timgit , it seems that this issue happens when integrating with strapi https://strapi.io/. If possible, I appreciate a lot your effort to investigate it.
The output
column should have the error message.
sure, here is the error message I got from output column
Finally, I found a workaround solution here and it seems that solved my issue: https://github.com/strapi/strapi/issues/18073 Thanks @timgit , @dimhold
Hi pg-boss team, Thanks for your effort in building this package, it has a lot of features I'm looking for. However, when trying to run the scheduled jobs, following the documentation, I have the error below. Could you please take a look? Please let me know if you need more detail to trace this error. Thanks a lot I'm using pg-boss 10.1.4 Node v20.10.0, "PostgreSQL 16.4 (Debian 16.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit"