From 40c47f158170b7a10f091a4acdd235eb4602c0c6 Mon Sep 17 00:00:00 2001 From: Darryl Norris Date: Mon, 6 Jul 2020 10:41:00 -0700 Subject: [PATCH] Fixing issue with the setMaxListeners (#240) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘ --- packages/puppeteer-extra-plugin-stealth/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/puppeteer-extra-plugin-stealth/index.js b/packages/puppeteer-extra-plugin-stealth/index.js index 774a239f..41336d8c 100644 --- a/packages/puppeteer-extra-plugin-stealth/index.js +++ b/packages/puppeteer-extra-plugin-stealth/index.js @@ -151,8 +151,10 @@ class StealthPlugin extends PuppeteerExtraPlugin { } async onBrowser(browser) { - // Increase event emitter listeners to prevent MaxListenersExceededWarning - browser.setMaxListeners(30) + if (browser && browser.setMaxListeners) { + // Increase event emitter listeners to prevent MaxListenersExceededWarning + browser.setMaxListeners(30) + } } }