Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'puppeteer-extra' : ProtocolError: Protocol error (Network.getCookies): Target closed. #76

Open
NabiKAZ opened this issue Apr 23, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@NabiKAZ
Copy link

NabiKAZ commented Apr 23, 2022

I use puppeteer-extra.
It don't have problem in normal use.
But when I set proxy: await useProxy(page, 'socks5://127.0.0.1:8080');
Complete code:

import puppeteer from 'puppeteer-extra';
import StealthPlugin from 'puppeteer-extra-plugin-stealth';
import useProxy from 'puppeteer-page-proxy';
puppeteer.use(StealthPlugin());

let options = {
	headless: false,
	devtools: true,
};
const browser = await puppeteer.launch(options);
const page = await browser.newPage();
await useProxy(page, 'socks5://127.0.0.1:8080');
await page.goto('http://api.ipify.org/');
var result = await page.content();
console.log(result);

await browser.close();

I get this error:

C:\>node test_proxy.mjs
<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">x.x.x.x</pre></body></html>
C:\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:230
                error: new Errors_js_1.ProtocolError(),
                       ^

ProtocolError: Protocol error (Network.getCookies): Target closed.
    at C:\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:230:24
    at new Promise (<anonymous>)
    at CDPSession.send (C:\node_modules\puppeteer\lib\cjs\puppeteer\common\Connection.js:226:16)
    at next (C:\node_modules\puppeteer-extra-plugin-stealth\evasions\sourceurl\index.js:32:41)
    at CDPSession.send (C:\node_modules\puppeteer-extra-plugin-stealth\evasions\sourceurl\index.js:57:18)
    at Object.getCookies (C:\node_modules\puppeteer-page-proxy\src\lib\cdp.js:6:38)
    at CookieHandler.getCookies (C:\node_modules\puppeteer-page-proxy\src\lib\cookies.js:84:51)
    at requestHandler (C:\node_modules\puppeteer-page-proxy\src\core\proxy.js:15:40)
    at $ppp_request_listener (C:\node_modules\puppeteer-page-proxy\src\core\proxy.js:82:15)
    at C:\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:219:52 {
  originalMessage: ''
}

Node.js v17.2.0

Of course, the code works, but at the end of it, an error appears when closing the browser.

There seems to be a problem closing the browser, because when I use it and cause a delay, there is no problem:

setTimeout(async function() {
  await browser.close();
}, 1000);

And also, when I use this, no problem:

await useProxy(page, null);
await browser.close();

But I do not know if this is a principle to prevent problems or if the error does not appear due to the delay in executing the command.

@Cuadrix Cuadrix added the bug Something isn't working label Oct 10, 2022
21jake added a commit to 21jake/nimble-scraper that referenced this issue Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants