Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/prober-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ export async function processDuePortScans(

for (const scan of (runningRows ?? []) as ScanRow[]) {
const job = (await q.getJob(scan.id)) as Job | undefined;
const age = Date.now() - new Date(scan.created_at).getTime();

if (!job) {
if (age > RUNNING_TIMEOUT_MS) {
// No job and an old row => the job was lost (not just slow to enqueue).
if (Date.now() - new Date(scan.created_at).getTime() > RUNNING_TIMEOUT_MS) {
await markFailed(supabase, scan.id, "prober job missing");
failed++;
}
Expand All @@ -168,7 +168,10 @@ export async function processDuePortScans(
} else if (state === "failed") {
await markFailed(supabase, scan.id, job.failedReason ?? "prober job failed");
failed++;
} else if (age > RUNNING_TIMEOUT_MS) {
} else if (Date.now() - job.timestamp > RUNNING_TIMEOUT_MS) {
// Measure the timeout from when the job was ENQUEUED (job.timestamp), not
// when the scan row was created — a row can sit `queued` a long time
// before a job exists, and timing out from created_at kills fresh jobs.
await markFailed(supabase, scan.id, "scan timed out");
failed++;
}
Expand Down
Loading