Cuadrix / puppeteer-page-proxy

Additional module to use with 'puppeteer' for setting proxies per page basis.
423 stars 99 forks source link

Cannot read property 'get' of undefined #57

Closed evinstar closed 1 year ago

evinstar commented 3 years ago

system: win10 node: 12.21.0 puppeteer: 1.14.0 puppeteer-page-proxy: 1.2.8

const puppeteer = require('puppeteer');
const useProxy = require('puppeteer-page-proxy');

(async ()=> {
    let browser = await puppeteer.launch();

    let page = await browser.newPage();
    await useProxy(page, 'http://127.0.0.1:1121');
    await browser.close();
})()

when I run such code, I get some error as below

(node:20688) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'get' of undefined at removeRequestListener (C:\Users\andy\projects\JS-Puppeteer\node_modules\puppeteer-page-proxy\src\core\proxy.js:48:38) at proxyPerPage (C:\Users\andy\projects\JS-Puppeteer\node_modules\puppeteer-page-proxy\src\core\proxy.js:80:5) at processTicksAndRejections (internal/process/task_queues.js:97:5) at async useProxy (C:\Users\andy\projects\JS-Puppeteer\node_modules\puppeteer-page-proxy\src\core\proxy.js:94:9) at async C:\Users\andy\projects\JS-Puppeteer\tests\useProxy.js:9:5 (node:20688) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:20688) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

evinstar commented 3 years ago

Solution: modify source code in puppeteer-page-proxy/src/core/proxy.js line 48 to const listeners = page.eventsMap && page.eventsMap.get(eventName);

ProteanCode commented 3 years ago

Same problem here

Cuadrix commented 1 year ago

use a newer version of puppeteer