feat(scrape): add warning to document if it was concurrency limited (#1348)

* feat(scrape): add warning to document if it was concurrency limited

* phrasing + test fix
This commit is contained in:
Gergő Móricz 2025-03-16 19:57:27 +01:00 committed by GitHub
parent 670ca84ae9
commit 200de9e7e7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View File

@ -97,7 +97,7 @@ describe("Billing tests", () => {
const rc2 = (await creditUsage()).remaining_credits;
expect(rc1 - rc2).toBe(12);
}, 300000);
}, 600000);
it("bills crawl correctly", async () => {
const rc1 = (await creditUsage()).remaining_credits;

View File

@ -84,6 +84,8 @@ async function addScrapeJobRaw(
// logger.error("Error sending notification (concurrency limit reached): ", error);
// });
}
webScraperOptions.concurrencyLimited = true;
await _addScrapeJobToConcurrencyQueue(
webScraperOptions,

View File

@ -923,6 +923,10 @@ async function processJob(job: Job & { id: string }, token: string) {
delete doc.rawHtml;
}
if (job.data.concurrencyLimited) {
doc.warning = "This scrape job was throttled at your current concurrency limit. If you'd like to scrape faster, you can upgrade your plan." + (doc.warning ? " " + doc.warning : "");
}
const data = {
success: true,
result: {