Skip to content

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

fix(crawl-status): missing partial data after cancel

Gergo Moricz06751a8e2103
diff --git a/apps/api/src/controllers/crawl-status.ts b/apps/api/src/controllers/crawl-status.ts
index 8a7b59e04..bc6de593b 100644
--- a/apps/api/src/controllers/crawl-status.ts
+++ b/apps/api/src/controllers/crawl-status.ts
@@ -23,14 +23,6 @@ export async function crawlStatusController(req: Request, res: Response) {
const isCancelled = await (await getWebScraperQueue().client).exists("cancelled:" + req.params.jobId);
- if (isCancelled) {
- return res.json({
- status: "failed",
- data: null,
- partial_data: [],
- });
- }
-
let progress = job.progress;
if(typeof progress !== 'object') {
progress = {
@@ -61,14 +53,14 @@ export async function crawlStatusController(req: Request, res: Response) {
const jobStatus = await job.getState();
res.json({
- status: jobStatus,
+ status: isCancelled ? "failed" : jobStatus,
// progress: job.progress(),
current,
current_url,
current_step,
total,
- data: data ? data : null,
- partial_data: jobStatus == 'completed' ? [] : partialDocs,
+ data: data && !isCancelled ? data : null,
+ partial_data: jobStatus == 'completed' && !isCancelled ? [] : partialDocs,
});
} catch (error) {
Logger.error(error);