“pm2.root.service is not a snap cgroup”无法使用 puppeteer 启动额外的浏览器

问题描述 投票:0回答:0

当我通过我的 nodejs 应用程序运行太多 puppeteer 浏览器时,我使用 pm2 来运行它。 80-85 浏览器后,它无法创建新的浏览器并使应用程序崩溃。当我检查内存和磁盘时,我有足够的空间。我的服务器是无头 Ubuntu。

我认为主要错误是

pm2-root.service is not a snap cgroup
但我不知道这是什么意思。

我的浏览器起始码:

....
    
          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);
    ....

返回错误:

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)

在那个错误之后,我的代码因这个错误而崩溃:

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)

有没有人遇到过这个问题:(或者有什么想法?

node.js typescript ubuntu puppeteer pm2
© www.soinside.com 2019 - 2024. All rights reserved.