fix(scrape): consider timeout property

This commit is contained in:
Gergo Moricz 2024-08-06 17:25:58 +02:00
parent 8566ece700
commit 3ae95a2740

View File

@ -47,7 +47,20 @@ export async function scrapeHelper(
origin: req.body.origin ?? defaultOrigin,
});
const doc = (await job.waitUntilFinished(scrapeQueueEvents, 60 * 1000))[0]; //60 seconds timeout
let doc;
try {
doc = (await job.waitUntilFinished(scrapeQueueEvents, timeout))[0]; //60 seconds timeout
} catch (e) {
if (e instanceof Error && e.message.startsWith("Job wait")) {
return {
success: false,
error: "Request timed out",
returnCode: 409,
}
} else {
throw e;
}
}
if (!doc) {
console.error("!!! PANIC DOC IS", doc, job);