Trouble launching browser with Puppeteer: Process failure

I’m trying to make a PDF file using Puppeteer, but I keep getting an error. The browser process won’t start. Here’s what I’ve got so far:

async function createPDF() {
  try {
    const browserInstance = await puppeteer.launch();
    const newTab = await browserInstance.newPage();

    await newTab.setContent(htmlContent);
    await newTab.emulateMediaType('screen');
    await newTab.pdf({
      path: './output/generated_doc.pdf',
      format: 'A4',
      printBackground: true
    });

    console.log('PDF created successfully');
    await browserInstance.close();
  } catch (error) {
    console.error('Oops, something went wrong:', error);
  }
}

createPDF();

The error message mentions something about ‘crashForExceptionInNonABIComplianceCodeRange’. Any ideas what might be causing this? I’m not sure if it’s a problem with my code or something else.

hey man, had similar problems b4. try adding some launch options like this:

const browser = await puppeteer.launch({
headless: true,
args: [‘–no-sandbox’]
});

this worked 4 me. also make sure ur puppeteer is up to date. good luck!

I’ve dealt with this exact issue before, and it can be frustrating. One thing that worked for me was running Puppeteer in non-headless mode. Try modifying your launch options like this:

const browserInstance = await puppeteer.launch({
headless: false,
args: [‘–disable-gpu’, ‘–no-sandbox’, ‘–disable-dev-shm-usage’]
});

This allows you to see what’s happening in the browser, which can be helpful for debugging. Also, make sure you have the latest version of Node.js installed, as older versions can sometimes cause compatibility issues with Puppeteer.

If you’re still having trouble, you might want to check your system’s antivirus or firewall settings. Sometimes they can interfere with Puppeteer’s ability to launch Chrome. Temporarily disabling them (if safe to do so) could help isolate the problem.

Lastly, if nothing else works, try using a specific Chrome version that’s known to be compatible with your Puppeteer version. You can do this by installing puppeteer-core and specifying the Chrome executable path explicitly.

I’ve encountered similar issues with Puppeteer before. The ‘crashForExceptionInNonABIComplianceCodeRange’ error often points to compatibility problems between Puppeteer and the installed Chrome version. First, try updating both Puppeteer and Chrome to their latest versions. If that doesn’t work, you might need to specify a custom Chrome executable path.

You can modify your launch options like this:

const browserInstance = await puppeteer.launch({
  executablePath: '/path/to/chrome',
  args: ['--no-sandbox', '--disable-setuid-sandbox']
});

Replace ‘/path/to/chrome’ with the actual path on your system. The additional args can help bypass some security restrictions that might be causing issues. If you’re still stuck, check your system’s firewall settings or try running the script with elevated privileges.