Skip to content

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

fix(crawl-status): hard error bug

Gergő Móricz712a138404d0
diff --git a/apps/api/src/controllers/v1/crawl-status.ts b/apps/api/src/controllers/v1/crawl-status.ts
index f150ddc4a..8493e855a 100644
--- a/apps/api/src/controllers/v1/crawl-status.ts
+++ b/apps/api/src/controllers/v1/crawl-status.ts
@@ -5,6 +5,7 @@ import { getScrapeQueue } from "../../services/queue-service";
import { supabaseGetJobById, supabaseGetJobsById } from "../../lib/supabase-jobs";
import { configDotenv } from "dotenv";
import { Job, JobState } from "bullmq";
+import { logger } from "../../lib/logger";
configDotenv();
export async function getJob(id: string) {
@@ -98,8 +99,12 @@ export async function crawlStatusController(req: RequestWithAuth<CrawlStatusPara
// both loops will break once we cross the byte counter
for (let ii = 0; ii < jobs.length && bytes < bytesLimit; ii++) {
const job = jobs[ii];
+ if (job.returnvalue === undefined) {
+ logger.warn("Job was considered done, but returnvalue is undefined!", { jobId: job.id });
+ continue;
+ }
doneJobs.push(job);
- bytes += JSON.stringify(job.returnvalue).length;
+ bytes += JSON.stringify(job.returnvalue ?? null).length;
}
}