Skip to content

Commit 6d48c70

Browse files
ralyodioclaude
andcommitted
fix(prober-queue): time out scans from job enqueue time, not created_at
First live scans false-failed ('scan timed out', completed:0): backlog rows sat 'queued' ~68 min before the sweep enqueued them, and the reconcile timed them out immediately because it measured age from created_at. Measure from job.timestamp so freshly-enqueued jobs get the full window. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 85494ad commit 6d48c70

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎lib/prober-queue.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ export async function processDuePortScans(
151151

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

156155
if (!job) {
157-
if (age > RUNNING_TIMEOUT_MS) {
156+
// No job and an old row => the job was lost (not just slow to enqueue).
157+
if (Date.now() - new Date(scan.created_at).getTime() > RUNNING_TIMEOUT_MS) {
158158
await markFailed(supabase, scan.id, "prober job missing");
159159
failed++;
160160
}
@@ -168,7 +168,10 @@ export async function processDuePortScans(
168168
} else if (state === "failed") {
169169
await markFailed(supabase, scan.id, job.failedReason ?? "prober job failed");
170170
failed++;
171-
} else if (age > RUNNING_TIMEOUT_MS) {
171+
} else if (Date.now() - job.timestamp > RUNNING_TIMEOUT_MS) {
172+
// Measure the timeout from when the job was ENQUEUED (job.timestamp), not
173+
// when the scan row was created — a row can sit `queued` a long time
174+
// before a job exists, and timing out from created_at kills fresh jobs.
172175
await markFailed(supabase, scan.id, "scan timed out");
173176
failed++;
174177
}

0 commit comments

Comments
 (0)