when I run too many puppeteer browsers via my nodejs app and i use pm2 to run it. After 80-85 browsers, it can't create new browsers and crash the app. When I check memory and disk I have enough space. My server is headless Ubuntu.
I think the main error is pm2-root.service is not a snap cgroup
But I don't know what it means.
My browser starting code:
....
const options = {
executablePath: '/snap/bin/chromium',
defaultViewport: null,
headless: true,
args: ['--start-fullscreen', "--disable-features=IsolateOrigins","--disable-setuid-sandbox", "--disable-site-isolation-trials", "--disable-features=BlockInsecurePrivateNetworkRequests",
"--disable-web-security", '--ignore-certificate-errors', '--ignore-certificate-errors-spki-list ']
}
options.args.push('--no-sandbox');
await puppeteer.launch(options);
....
system info:
uname -a
Linux pot-n7 5.15.0-52-generic #58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
nano /etc/os-release
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy
apt list snapd -a
Listing... Done
snapd/jammy-updates 2.58+22.04 amd64 [upgradable from: 2.57.5+22.04ubuntu0.1]
snapd/jammy-security,now 2.57.5+22.04ubuntu0.1 amd64 [installed,upgradable to: 2.58+22.04]
snapd/jammy 2.55.3+22.04 amd64
snap --version
snap 2.58.3
snapd 2.58.3
series 16
ubuntu 22.04
kernel 5.15.0-52-generic
snap list core
error: no matching snaps installed
return error :
EROROR Error: Failed to launch the browser process!
0|npm | /system.slice/pm2-root.service is not a snap cgroup
0|npm | TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
0|npm | at onClose (/var/www/twitch-client/node_modules/puppeteer/src/node/BrowserRunner.ts:327:9)
0|npm | at Interface.<anonymous> (/var/www/twitch-client/node_modules/puppeteer/src/node/BrowserRunner.ts:313:16)
0|npm | at Interface.emit (node:events:525:35)
0|npm | at Interface.close (node:readline:590:8)
0|npm | at Socket.onend (node:readline:280:10)
0|npm | at Socket.emit (node:events:525:35)
0|npm | at endReadableNT (node:internal/streams/readable:1358:12)
0|npm | at processTicksAndRejections (node:internal/process/task_queues:83:21)
after that error, my code crashes with this error:
0|npm | TypeError: Cannot read properties of undefined (reading 'pages')
0|npm | at /var/www/twitch-client/src/autoBrowser.service.ts:98:47
0|npm | at runMicrotasks (<anonymous>)
0|npm | at processTicksAndRejections (node:internal/process/task_queues:96:5)
Did anyone faced with this issue :( or has any idea?