New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
puppeteer script randomly hangs #7225
Comments
I have a similar problem with Playwright (which is based on Puppeteer): microsoft/playwright#6796 Here is the equivalent of my code randomly hanging at const puppeteer = require('puppeteer');
(async () => {
try {
for (let i = 0; i < 100; ++i) {
console.log(new Date(), i);
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium',
});
const page = await browser.newPage();
await page.close();
await browser.close();
}
} catch (err) {
console.log(new Date(), err);
}
})(); |
I have same issue, it just hangs at the newPage promise from what I gather from error when I manually kill chromium.
I upgraded from puppeteer v6.0.0 where was working fine and this issue appears for me in both 9.1.1 and 10.1.0 |
Tested this again with Node16, puppeteer 11 and Chromium 93 on Alpine |
Friends, apologies for being so slow to update. I have managed to get this to be reliable by using the following code. I stumbled across it by accident, and have no idea why it works but for my purposes it seems to be reliable. var myArgs = process.argv.slice(2); const minimal_args = [ const puppeteer = require('puppeteer'); (async () => { If this helps you move forward I'm pleased! |
I still regularly see this in Docker on multiple OS's (Alpine, Debian, Fedora), with multiple versions of Chrome/Chromium (93+). My solution was to just add a retry function to |
Hello, puppeteer.launch({
headless: process.env.NODE_ENV === 'production',
ignoreHTTPSErrors: true,
args: ['--disable-infobars'],
timeout: 30000 // 30s
}) I was not able to reproduce the issue after 30 min of testing. |
We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days. |
My puppeeter hangs when going throw pages. It doesn't throw any error whatsoever.
|
Closing in favour of #7475 as it appears none of the repros here are complete and commenters report different not really related problems in the thread. If you believe this issue still affects you, please open a new issue with complete information on how to reproduce it. Note that if you run many browser instances in parallel, you might run out of the system resources leading to timeouts. |
Steps to reproduce
Tell us about your environment:
What steps will reproduce the problem?
When I run "node make_canvas.js arg1 arg2" (from /home/ikadmin) it sometimes works and sometimes hangs.
Please include code that reproduces the issue.
// make_canvas.js $ref $canvas_path
var myArgs = process.argv.slice(2);
const minimal_args = [
'--autoplay-policy=user-gesture-required',
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-component-update',
'--disable-default-apps',
'--disable-dev-shm-usage',
'--disable-domain-reliability',
'--disable-features=AudioServiceOutOfProcess',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-notifications',
'--disable-offer-store-unmasked-wallet-cards',
'--disable-popup-blocking',
'--disable-print-preview',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-setuid-sandbox',
'--disable-speech-api',
'--disable-sync',
'--hide-scrollbars',
'--ignore-gpu-blacklist',
'--metrics-recording-only',
'--mute-audio',
'--no-default-browser-check',
'--no-first-run',
'--no-pings',
'--no-sandbox',
'--no-zygote',
'--password-store=basic',
'--use-gl=swiftshader',
'--use-mock-keychain',
'--allow-insecure-localhost',
];
const puppeteer = require('puppeteer');
const VIEWPORT = {width: 1024, height: 1500};
const URL = 'http://localhost/make-canvas/'+myArgs[0];
(async () => {
const browser = await puppeteer.launch({args:minimal_args,headless:true,ignoreHTTPSErrors: true,userDataDir:'/home/ikadmin/puppeteer_cache'});
const page = await browser.newPage();
await page.setViewport(VIEWPORT);
//await page.setCookie({name:'GNB_cookies',value:'dismiss',domain:'goodnewsbig.com'});
await page.goto(URL, { waitUntil: 'networkidle0' });
const modal = await page.waitForSelector('#gobig');
await modal.screenshot({ path: myArgs[1], type: 'jpeg' });
await page.close();
await browser.close();
})()
ikadmin 3900 3893 0 15:18 ? 00:00:00 /home/ikadmin/node_modules/puppeteer/.local-chromium/linux-869685/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=Translate --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --enable-blink-features=IdleDetection --user-data-dir=/home/ikadmin/puppeteer_cache --headless --hide-scrollbars --mute-audio --autoplay-policy=user-gesture-required --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-domain-reliability --disable-features=AudioServiceOutOfProcess --disable-hang-monitor --disable-ipc-flooding-protection --disable-notifications --disable-offer-store-unmasked-wallet-cards --disable-popup-blocking --disable-print-preview --disable-prompt-on-repost --disable-renderer-backgrounding --disable-setuid-sandbox --disable-speech-api --disable-sync --hide-scrollbars --ignore-gpu-blacklist --metrics-recording-only --mute-audio --no-default-browser-check --no-first-run --no-pings --no-sandbox --no-zygote --password-store=basic --use-gl=swiftshader --use-mock-keychain --allow-insecure-localhost --remote-debugging-port=0 about:blank
ikadmin 3915 3900 0 15:18 ? 00:00:00 /home/ikadmin/node_modules/puppeteer/.local-chromium/linux-869685/chrome-linux/chrome --type=gpu-process --field-trial-handle=1442900448426305919,10311597978264912417,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=AudioServiceOutOfProcess,PaintHolding --no-sandbox --disable-dev-shm-usage --disable-breakpad --headless --ozone-platform=headless --headless --gpu-preferences=UAAAAAAAAAAgAAAQAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA= --use-gl=swiftshader --override-use-software-gl-for-tests --shared-files
ikadmin 3919 3900 0 15:18 ? 00:00:00 /home/ikadmin/node_modules/puppeteer/.local-chromium/linux-869685/chrome-linux/chrome --type=renderer --no-sandbox --disable-dev-shm-usage --autoplay-policy=user-gesture-required --disable-background-timer-throttling --disable-breakpad --disable-notifications --disable-speech-api --enable-automation --force-color-profile=srgb --no-zygote --remote-debugging-port=0 --allow-pre-commit-input --ozone-platform=headless --field-trial-handle=1442900448426305919,10311597978264912417,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=AudioServiceOutOfProcess,PaintHolding --disable-gpu-compositing --enable-blink-features=IdleDetection --lang=en-GB --headless --lang=en-GB --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=3 --shared-files=v8_context_snapshot_data:100
ikadmin 3920 3900 0 15:18 ? 00:00:00 /home/ikadmin/node_modules/puppeteer/.local-chromium/linux-869685/chrome-linux/chrome --type=renderer --no-sandbox --disable-dev-shm-usage --autoplay-policy=user-gesture-required --disable-background-timer-throttling --disable-breakpad --disable-notifications --disable-speech-api --enable-automation --force-color-profile=srgb --no-zygote --remote-debugging-port=0 --allow-pre-commit-input --ozone-platform=headless --field-trial-handle=1442900448426305919,10311597978264912417,131072 --enable-features=NetworkService,NetworkServiceInProcess --disable-features=AudioServiceOutOfProcess,PaintHolding --disable-gpu-compositing --enable-blink-features=IdleDetection --lang=en-GB --headless --lang=en-GB --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=4 --shared-files=v8_context_snapshot_data:100
What is the expected result?
I get screenshot of the modal written to my file, and the process completes and tidies everything up.
I am using some recommendations I found (minimal_args, and userDataDir) to try and make the screenshot as efficient as possible. When the script runs ok I get my file fine.
What happens instead?
If it hangs, nothing. I have tried to read up how to trap errors /crashes, but the frustrating thing is when it works it completes in a few seconds. When I have got this step stable, my last addition is to try and exec the script from php. So far that has never worked and simply leaves the hanging processes.
I feel there is something fundamental left hanging around as far as the headless browser is concerned and would appreciate some guidance/help to resolve this issue please.
The text was updated successfully, but these errors were encountered: