I'm trying to launch multiple instances of browser to handle my tasks simultaneously. To illuminate I used the following code:
export async function play() {
const b1 = await launchBrowserPuppeteer()
const b2 = await launchBrowserPuppeteer()
const b3 = await launchBrowserPuppeteer()
}
where:
export const launchBrowserPuppeteer = async () => {
const options = {
headless: false,
userDataDir: env.chromeUserDataDir,
executablePath: env.chromeExecutablePath,
}
return await puppeteer.launch(options);
}
I expected three separate windows getting opened, but what happens is like this:
First a chromium window is opened (b1), next a new tab is opened inside that window (b2), and then an exception is thrown:
Error: Failed to launch the browser process!
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (\node_modules\puppeteer\src\node\BrowserRunner.ts:268:9)
at ChildProcess.<anonymous> (\node_modules\puppeteer\src\node\BrowserRunner.ts:255:61)
at ChildProcess.emit (node:events:539:35)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
When I close()
browsers and launch a new one, I get no errors. Is launching multiple browsers generally supported by puppeteer, or I'm using it in a wrong way?
Any suggestion is highly appreciated.
I'm on a windows machine and the chromium version is 102.