Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. π₯
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
fix(queue-worker): manually renew lock (testing)
Gergo Moricz7bb922071cce
diff --git a/apps/api/src/scraper/WebScraper/index.ts b/apps/api/src/scraper/WebScraper/index.tsindex e667fa6be..c3834bcd3 100644--- a/apps/api/src/scraper/WebScraper/index.ts+++ b/apps/api/src/scraper/WebScraper/index.ts@@ -94,7 +94,7 @@ export class WebScraperDataProvider {const jobStatus = await job.getState();if (jobStatus === "failed") {Logger.info(- "Job has failed or has been cancelled by the user. Stopping the job..."+ "Job " + job.id + " has failed or has been cancelled by the user. Stopping the job...");return [] as Document[];}diff --git a/apps/api/src/services/queue-worker.ts b/apps/api/src/services/queue-worker.tsindex e77678092..e46ffc1a6 100644--- a/apps/api/src/services/queue-worker.ts+++ b/apps/api/src/services/queue-worker.ts@@ -22,6 +22,11 @@ const wsq = getWebScraperQueue();async function processJob(job: Job, done) {Logger.debug(`π Worker taking job ${job.id}`);+ const lockInterval = setInterval(() => {+ Logger.debug(`π Renewing lock for ${job.id}`);+ job.extendLock(60000);+ }, 15000);+try {job.progress({current: 1,@@ -62,6 +67,7 @@ async function processJob(job: Job, done) {origin: job.data.origin,});Logger.debug(`π Job done ${job.id}`);+ clearInterval(lockInterval);done(null, data);} catch (error) {Logger.error(`π Job errored ${job.id} - ${error}`);@@ -108,8 +114,9 @@ async function processJob(job: Job, done) {pageOptions: job.data.pageOptions,origin: job.data.origin,});+ clearInterval(lockInterval);done(null, data);- }+ }}wsq.process(