Encountering Problems Launching Puppeteer with macOS Default Browser

I’m attempting to run Puppeteer with my system-installed Chrome on macOS, but after the browser opens and a new tab is created, an error occurs. I need help identifying what might be causing this issue. Below is my current implementation:

const chromeAutomation = require('puppeteer');
const pathModule = require('path');

async function startChrome() {
  const profilePath = pathModule.join(process.env.HOME, 'Library/Application Support/Google/Chrome');
  try {
    const instance = await chromeAutomation.launch({
      headless: false,
      executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
      userDataDir: profilePath,
      args: [
        '--start-maximized',
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--profile-directory=Default'
      ],
      defaultViewport: null,
      ignoreDefaultArgs: ['--enable-automation']
    });
    
    const newTab = await instance.newPage();
    await newTab.goto('https://www.example.com/');
  } catch (err) {
    console.error('Error launching Chrome:', err);
    throw err;
  }
}

startChrome();

hey, i had a simmilar prob too. try using a fresh profile instead of your chrome one. also check your puppteer version for compatibility issues. maybe swap out some default args if needed. good luck!

Upon facing a similar issue, I discovered that using an existing user data profile might impose restrictions due to conflicting session data and automation settings. It is worth trying a temporary profile to determine if the device-specific settings are causing the error. Verifying that the Puppeteer version aligns with your installed version of Chrome also helped in my experience. Additionally, consider simplifying the added arguments to ensure none are conflicting with Puppeteer’s default automation workflows. These adjustments might provide a clearer path to isolating the error source.

hey, i got a hint by cleaning old chrome lock files. try killing any stray chrome process, then launch puppeteer without extra args. sometimes leftover settings create issues. give it a go!

After encountering similar issues, I found that when using the system-installed Chrome on macOS with Puppeteer, it is important to ensure there are no conflicts with other running Chrome instances. My experience taught me that Chrome may already be locking configuration files even when not using it for browsing, which can lead to unexpected errors. I managed to overcome this problem by stopping all Chrome processes before launching Puppeteer. In addition, I experimented with minimizing the use of redundant launch flags that can inadvertently override Puppeteer’s internal settings, resulting in a more stable execution.