Skip to content

Commit

Permalink
handle stalled job removal
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Dec 19, 2024
1 parent 1ccab05 commit d2f2087
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion api/src/modules/import-data/workers/import-data.consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export class ImportDataConsumer {

@OnQueueFailed()
async onJobFailed(job: Job<ExcelImportJob>, err: any): Promise<void> {
await job.remove();
if (this.isJobStalled(err)) {
return this.removeJob(job);
}
const task: Task | undefined = await this.tasksService.updateImportTask({
taskId: job.data.taskId,
newStatus: TASK_STATUS.FAILED,
Expand Down Expand Up @@ -87,4 +89,12 @@ export class ImportDataConsumer {
async readImportDataJob(job: Job<ExcelImportJob>): Promise<void> {
await this.importDataService.processImportJob(job);
}

private isJobStalled(err: Error): boolean {
return err.message === 'job stalled more than allowable limit';
}

private async removeJob(job: Job<ExcelImportJob>): Promise<void> {
return job.remove();
}
}

0 comments on commit d2f2087

Please sign in to comment.