Search code examples
javascriptnode.jsgoogle-chromepuppeteerremote-debugging

Ignore Puppeteer arg "--remote-debugging-port=0"


I was wondering why the arg "--remote-debugging-port=0" is still on even though I called it between the ignoreDefaultArgs of the browser.

Here's my script

(async()=>{
    const browser = await puppeteer.launch({
        executablePath:"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
        headless:false,
        devtools:false,
        ignoreDefaultArgs:[
            '--remote-debugging-port=0',
        ],
        args:[
            '--user-data-dir=C:/Users/GIULIO/AppData/Local/Google/Chrome/User Data/Profile 2',
        ]
    })
    const page = (await browser.pages())[0];
    await page.goto('chrome://version/')


And here's what I get when I go to chrome://version

enter image description here


Solution

  • --remote-debugging-port is part of the wiring puppeteer needs to set up to be able to connect to chrome. Puppeteer can connect to chrome in two ways:

    • Using pipes puppeteer.launch({pipe: true});. This will add the flag --remote-debugging-pipe.
    • Using WebSockets puppeteer.launch({pipe: false});. This will add the flag --remote-debugging-port=0. Which will tell Chromium that remote debugging is required and that he can pick any free port.

    There is no way to get rid of any of these flags because it's part of the basic communication.