From daa7fc58f60a05be41e5977294434b13756c9141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20M=C3=B3ricz?= Date: Fri, 30 May 2025 17:36:51 +0200 Subject: [PATCH] fix: proper level --- apps/api/src/services/queue-worker.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/api/src/services/queue-worker.ts b/apps/api/src/services/queue-worker.ts index 1a1ffc10..36bc1a26 100644 --- a/apps/api/src/services/queue-worker.ts +++ b/apps/api/src/services/queue-worker.ts @@ -1130,10 +1130,6 @@ async function processJob(job: Job & { id: string }, token: string) { logger.info(`🐂 Worker taking job ${job.id}`, { url: job.data.url }); const start = job.data.startTime ?? Date.now(); const remainingTime = job.data.scrapeOptions.timeout ? (job.data.scrapeOptions.timeout - (Date.now() - start)) : undefined; - if (remainingTime !== undefined && remainingTime < 0) { - throw new Error("timeout"); - } - const signal = remainingTime ? AbortSignal.timeout(remainingTime) : undefined; const costTracking = new CostTracking(); @@ -1145,6 +1141,11 @@ async function processJob(job: Job & { id: string }, token: string) { current_url: "", }); + if (remainingTime !== undefined && remainingTime < 0) { + throw new Error("timeout"); + } + const signal = remainingTime ? AbortSignal.timeout(remainingTime) : undefined; + if (job.data.crawl_id) { const sc = (await getCrawl(job.data.crawl_id)) as StoredCrawl; if (sc && sc.cancelled) {