如何修复Puppeteer的唯一保证工作的Chrome版本是xyz错误?

lnvxswe2  于 2023-05-04  发布在  Go
关注(0)|答案(1)|浏览(104)

Chrome OS版本:谷歌浏览器60.0.3112.113
操作系统版本:操作系统:CentOs7 3.10.0-693.11.6.el7.x86_64
下面是我的代码

const puppeteer = require('puppeteer-core'); 
const fs = require('fs'); 

let browser = null;

const chromeOptions = {
    executablePath:' /usr/bin/google-chrome-stable', 
    headless:true, 
    ignoreDefaultArgs:["--enable-automation"], 
    args: ['--start-fullscreen',"--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu"], 
    slowMo:5,
    timeout:30000,
    defaultViewport: null
};

async function getBrowser(){        
    if(null == browser){
        browser  = await puppeteer.launch(chromeOptions);
    }
    return browser;
}

async function closeBrowser(){
    if(browser) {
        await browser.close(); 
    }
}

(async function main() {
    
        
 await getBrowser();
 await browser.newPage();                
            
        
})();

我得到了以下错误。
(node:24642)UnhandledPromiseRejectionWarning:超时错误:尝试连接到Chrome时在3000毫秒后超时!唯一可以保证正常工作的Chrome版本是r594312在Timeout.onTimeout(/opt/xxx/node-v14.16.0-linux-x64/lib/node_modules/npm/node_modules/puppeteer-core/lib/Launcher.js:350:14)在listOnTimeout(internal/timers.js:554:17)在processTimers(internal/timers.js:497:7)
有没有办法解决这个错误?

wwodge7n

wwodge7n1#

我得到了同样的错误。更新chrome到最新版本。

相关问题