Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(scrape): consider timeout property

Gergo Moricz3ae95a2740e1
diff --git a/apps/api/src/controllers/scrape.ts b/apps/api/src/controllers/scrape.ts
index aa17d6285..f024bce87 100644
--- a/apps/api/src/controllers/scrape.ts
+++ b/apps/api/src/controllers/scrape.ts
@@ -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);