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.

Make response.status() guard stricter in PuppeteerCrawler

Ondra Urban74ac6a224dec
diff --git a/src/crawlers/puppeteer_crawler.js b/src/crawlers/puppeteer_crawler.js
index 676f08613..e3a7a4c48 100644
--- a/src/crawlers/puppeteer_crawler.js
+++ b/src/crawlers/puppeteer_crawler.js
@@ -382,9 +382,12 @@ class PuppeteerCrawler {
}
}
- if (this.useSessionPool) {
- const statusCode = response && response.status();
- this._throwOnBlockedRequest(session, statusCode);
+ if (this.useSessionPool && response) {
+ if (typeof response === 'object' && typeof response.status === 'function') {
+ this._throwOnBlockedRequest(session, response.status());
+ } else {
+ this.log.debug('Got a malformed Puppeteer response.', { request, response });
+ }
}
await this.puppeteerPool.serveLiveViewSnapshot(page);