No issue in windows.. But in production server ubuntu, I’m getting this error after goto function
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
const url: String = login.url;
const page: any = await browser.newPage();
await page.setUserAgent('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36');
await page.goto(url, { waitUntil: 'networkidle2' });
await page.setViewport({
width: 1520,
height: 800,
deviceScaleFactor: 1,
isMobile: false
});
chromium-browser installed, puppeteer installed and some others like libgbm-dev or something
Anyone tell me whats the issue?
If you need any more informations please comment…
2
Answers
In my case, I was running an Ubuntu server with 512MB memory that could not handle running my scripts. I figured this out by writing a simple scraper that visited Google, which worked fine. I then ran my more intensive scrapers, and watched memory usage via
htop
, while they failed to execute and giving me a timeout error.I upgraded the server two 2gb of memory, and everything worked fine. You might not need to upgrade all the way to 2gb, but I did just in case.
Puppeteer sometimes require lot of time to answer.
in my case: Puppeteer-19.4.1 Ubuntu-20.04.1 LTS (server) with 1gb RAM, i solve the issue just increasing "page.goto" timeout at 2 minutes.