Skip to content

Commit

Permalink
fix(queue): catch exceptions in scheduled runs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicotsx committed Dec 23, 2024
1 parent 76ff593 commit bdf5a71
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/backend/src/modules/queue/queue.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ export class Queue<T extends ZodSchema, R extends ZodSchema<{ success: boolean;
throw new Error('Invalid event data');
}

cron.schedule(cronPattern, () => {
this.rpcClient.send(this.queueName, eventData.data);
cron.schedule(cronPattern, async () => {
try {
await this.rpcClient.send(this.queueName, eventData.data);
} catch (e) {
console.error('Error in cron job:', e);
}
});
}
}

0 comments on commit bdf5a71

Please sign in to comment.