Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

refactor: add timeout for adaptive crawler's `enqueueLinks` waitFor call

Martin Adámek37805479e591
diff --git a/packages/playwright-crawler/src/internals/adaptive-playwright-crawler.ts b/packages/playwright-crawler/src/internals/adaptive-playwright-crawler.ts
index b8abcc8f8..7f2f89b0d 100644
--- a/packages/playwright-crawler/src/internals/adaptive-playwright-crawler.ts
+++ b/packages/playwright-crawler/src/internals/adaptive-playwright-crawler.ts
@@ -404,10 +404,10 @@ export class AdaptivePlaywrightCrawler extends PlaywrightCrawler {
return playwrightContext.parseWithCheerio();
},
- async enqueueLinks(options = {}) {
+ async enqueueLinks(options = {}, timeoutMs = 5_000) {
const selector = options.selector ?? 'a';
const locator = playwrightContext.page.locator(selector).first();
- await locator.waitFor();
+ await locator.waitFor({ timeout: timeoutMs, state: 'attached' });
const urls = await extractUrlsFromPage(
playwrightContext.page,