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.

Puppeteer pool - fix

Marek Trunkat1325cb8e07d4
diff --git a/src/puppeteer_pool.js b/src/puppeteer_pool.js
index 0cb843468..e0ad68885 100644
--- a/src/puppeteer_pool.js
+++ b/src/puppeteer_pool.js
@@ -220,8 +220,7 @@ export default class PuppeteerPool {
browser.on('targetdestroyed', () => {
instance.activePages--;
- // NOTE: we are killing instance when number of pages is 1 because there is always about:blank page.
- if (instance.activePages === 1 && this.retiredInstances[id]) {
+ if (instance.activePages === 0 && this.retiredInstances[id]) {
// Run this with a delay, otherwise page.close() that initiated this 'targetdestroyed' event
// might fail with "Protocol error (Target.closeTarget): Target closed."
// TODO: Alternatively we could close here the first about:blank tab, which will cause