Skip to content

Commit

Permalink
clear intervals before shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
f-w committed Dec 5, 2024
1 parent 6962547 commit 60668d4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/queue/notification-queue-consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ export class NotificationQueueConsumer
}
}

private timeouts = [];
async process(job: Job) {
this.logger.debug(job?.id);
const notification = await this.notificationsService.findOne(
Expand All @@ -319,12 +320,17 @@ export class NotificationQueueConsumer
updated: new Date(),
});
}, 300000);
this.timeouts.push(hbTimeout);
await this.broadcastToSubscriberChunk(notification, job);
clearTimeout(hbTimeout);
this.timeouts.splice(this.timeouts.indexOf(hbTimeout), 1);
clearInterval(hbTimeout);
}
}

async beforeApplicationShutdown() {
for (const t of this.timeouts) {
clearInterval(t);
}
await this.worker.close();
}

Expand Down

0 comments on commit 60668d4

Please sign in to comment.