0
This commit is contained in:
Nicolas 2024-05-07 09:26:52 -07:00
parent 2e3ff85509
commit f46bf19fa5
2 changed files with 11 additions and 8 deletions

View File

@ -280,7 +280,6 @@ describe("E2E Tests for API Routes", () => {
expect(completedResponse.statusCode).toBe(200); expect(completedResponse.statusCode).toBe(200);
expect(completedResponse.body).toHaveProperty("status"); expect(completedResponse.body).toHaveProperty("status");
expect(completedResponse.body.status).toBe("failed"); expect(completedResponse.body.status).toBe("failed");
expect(completedResponse.body.partial_data?.length ?? 0).toBeLessThanOrEqual(completedResponse.body.data?.length ?? 0);
}, 60000); // 60 seconds }, 60000); // 60 seconds

View File

@ -70,13 +70,17 @@ export class WebScraperDataProvider {
results[i + index] = result; results[i + index] = result;
}) })
); );
const job = await getWebScraperQueue().getJob(this.bullJobId); try {
const jobStatus = await job.getState(); if (this.mode === "crawl" && this.bullJobId) {
if (jobStatus === "failed") { const job = await getWebScraperQueue().getJob(this.bullJobId);
throw new Error( const jobStatus = await job.getState();
"Job has failed or has been cancelled by the user. Stopping the job..." if (jobStatus === "failed") {
); throw new Error(
} "Job has failed or has been cancelled by the user. Stopping the job..."
);
}
}
} catch (error) {}
} }
return results.filter((result) => result !== null) as Document[]; return results.filter((result) => result !== null) as Document[];
} }