Skip to content

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

fix(queue-worker): call webhook after job is in DB

Gergő Móricz7e73b015996f
diff --git a/apps/api/src/services/queue-worker.ts b/apps/api/src/services/queue-worker.ts
index 601e319e7..44503732e 100644
--- a/apps/api/src/services/queue-worker.ts
+++ b/apps/api/src/services/queue-worker.ts
@@ -1161,21 +1161,6 @@ async function processJob(job: Job & { id: string }, token: string) {
document: doc,
};
- if (job.data.webhook && job.data.mode !== "crawl" && job.data.v1) {
- logger.debug("Calling webhook with success...", {
- webhook: job.data.webhook,
- });
- await callWebhook(
- job.data.team_id,
- job.data.crawl_id,
- data,
- job.data.webhook,
- job.data.v1,
- job.data.crawlerOptions !== null ? "crawl.page" : "batch_scrape.page",
- true,
- );
- }
-
if (job.data.crawl_id) {
const sc = (await getCrawl(job.data.crawl_id)) as StoredCrawl;
@@ -1261,6 +1246,21 @@ async function processJob(job: Job & { id: string }, token: string) {
true,
);
+ if (job.data.webhook && job.data.mode !== "crawl" && job.data.v1) {
+ logger.debug("Calling webhook with success...", {
+ webhook: job.data.webhook,
+ });
+ await callWebhook(
+ job.data.team_id,
+ job.data.crawl_id,
+ data,
+ job.data.webhook,
+ job.data.v1,
+ job.data.crawlerOptions !== null ? "crawl.page" : "batch_scrape.page",
+ true,
+ );
+ }
+
indexJob(job, doc);
logger.debug("Declaring job as done...");