I am using the following script to launch a Puppeteer instance:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: false, // show the browser
devtools: true, // open dev tools
defaultViewport: null, // ensure that browser viewport fills the window
args: [
'--disable-web-security', // disable CORS (be careful)
],
});
// navigate to the Angular page
const page = await browser.newPage();
page.goto('http://localhost:4200');
})();
Since upgrading to macOS Monterey, I get the following error when running the script:
UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
[86046:259:1202/104944.082215:FATAL:process_singleton_posix.cc(246)] Check failed: SetupSockAddr(path, addr). Socket path too long: /var/folders/qy/dsjty77j5p545xnfk2mp3j6m0000gn/T/com.apple.shortcuts.mac-helper/.org.chromium.Chromium.G3zxw9/SingletonSocket
This happens with any script that runs Puppeteer on my system.
It looks like Puppeteer is trying to launch using a config path from an instance that Shortcuts has previously launched, and the path is too long for a socket path. I still get the error if I'm not running the script from a shortcut.
As a temporary fix I have been providing the executablePath property to Puppeteer:
const browser = await puppeteer.launch({
...
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
});
This isn't ideal, but does the trick. Any ideas how I can force Puppeteer to reset to no longer use the Shortcuts path?