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.

Fixing Puppeteer pool - errors of page.goto() not catched

Marek Trunkat49085bb663c6
diff --git a/src/puppeteer_crawler.js b/src/puppeteer_crawler.js
index 7c63d7a20..a8de1a81d 100644
--- a/src/puppeteer_crawler.js
+++ b/src/puppeteer_crawler.js
@@ -247,8 +247,9 @@ export default class PuppeteerCrawler {
const page = await this.puppeteerPool.newPage();
try {
- const gotoPromise = this.gotoFunction({ page, request, puppeteerPool: this.puppeteerPool });
- const pageOperationsPromise = gotoPromise.then((response) => {
+ const pageOperationsPromise = this
+ .gotoFunction({ page, request, puppeteerPool: this.puppeteerPool })
+ .then((response) => {
return Promise.race([
this.handlePageFunction({ page, request, puppeteerPool: this.puppeteerPool, response }),
createTimeoutPromise(this.handlePageTimeoutSecs * 1000, 'PuppeteerCrawler: handlePageFunction timed out.'),