record last finished timestamp for failures

This commit is contained in:
Alex Holliday committed 2026-06-22 09:58:11 -07:00
1 parent 10174da4f0
commit 9db4e557b3
3 files changed
+3 -1

No files matched your search

@@ -127,6 +127,7 @@ class MongoJobsRepository implements IJobsRepository {
nextScheduledAt: now + BACKOFF_MS,
lockedBy: null, // Remove lock
lockedUntil: null,
lastFinishedAt: now, // a failed run still finished used in getMetrics for failedAt timestamp
lastFailReason: error instanceof Error ? error.message : String(error),
},
$inc: {
@@ -258,6 +258,7 @@ describe("MongoJobsRepository", () => {
const row = await readRow("check:mon-1");
expect(row?.nextScheduledAt).toBe(NOW + BACKOFF_MS);
expect(row?.lastFailReason).toBe("connection refused");
expect(row?.lastFinishedAt).toBe(NOW);
expect(row?.failCount).toBe(3);
expect(row?.lockedBy).toBeNull();
expect(row?.lockedUntil).toBeNull();
@@ -680,7 +680,7 @@ describe("DBQueueWorker", () => {
expect(page.count).toBe(1);
expect(page.jobs).toHaveLength(1);
expect(page.jobs[0]).toEqual(expect.objectContaining({ monitorId: "m1", monitorType: "check", monitorInterval: 60000, repeat: 60000 }));
expect(page.jobs[0]).toEqual(expect.objectContaining({ monitorId: "m1", monitorType: "check", monitorInterval: 60000 }));
});
it("falls back to the job id for monitorId when refId is null (global jobs)", async () => {