Improve event timeout with heartbeat_at

This commit is contained in:
Dominic Ferrando
2026-07-18 01:10:03 -04:00
parent c24002eaca
commit e4cb2da9cc
4 changed files with 15 additions and 6 deletions
+3 -2
View File
@@ -104,7 +104,7 @@ export class EventQueue<G extends string, T extends Record<string, EventTypeOpti
if (!front) return;
const result = await db.updateTable("events")
.set({ started_at: new Date() })
.set({ started_at: new Date(), heartbeat_at: new Date() })
.where("id", "=", front.id)
.where("started_at", "is", null)
.where((eb) =>
@@ -195,7 +195,7 @@ export class EventQueue<G extends string, T extends Record<string, EventTypeOpti
try {
Value.Assert(typeCfg.schemas.payload, event.payload);
await typeCfg.processor(event.payload, (state) => this.Events.setState(event.id, state), event.id);
await typeCfg.processor(event.payload, (s) => this.Events.setState(event.id, s), event.id);
await this.Events.resolve(event.id);
}
catch (err) {
@@ -236,6 +236,7 @@ export class EventQueue<G extends string, T extends Record<string, EventTypeOpti
.set((eb) => ({
errors: type === "error" ? eb("errors", "+", 1) : eb.ref("errors"),
rate_limits: type === "ratelimit" ? eb("rate_limits", "+", 1) : eb.ref("rate_limits"),
heartbeat_at: null,
started_at: null,
ended_at: null,
has_failed: false,