Error generating PDFs: Protocol error (Page.printToPDF): Target closed.
See original GitHub issue- Puppeteer version: puppeteer@1.5.0-next.1528948338383
- Chromium 66.0.3359.181 Built on Ubuntu , running on Ubuntu 17.10
- Node.js version: v9.11.2
- Fails on VirtualBox VM with plentiful resources (4cores, >8GB mem free)
Also an issue inside docker container with puppeteer 1.0.0, Ubuntu 18.04 and node v8.
What steps will reproduce the problem?
(async () => {
const browser = await puppeteer.launch({
executablePath: '/usr/bin/chromium-browser',
args: ['--headless', '--disable-gpu', '--full-memory-crash-report', '--unlimited-storage',
'--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage'],
});
const page = await browser.newPage();
await page.goto(url, {waitUntil: 'networkidle0'});
await page.pdf({path: outfile, format: 'A4'});
await browser.close();
})().catch(error => {
console.error(error);
process.exit(1);
});
What is the expected result?
PDF file saved to outfile
, exit code 0
What happens instead?
chromium-browser goes 100% CPU at page.pdf()
and after 35s:
{ Error: Protocol error (Page.printToPDF): Target closed.
at Promise (/home/jon/dev/web-exporter/node_modules/puppeteer/lib/Connection.js:202:56)
at new Promise (<anonymous>)
at CDPSession.send (/home/jon/dev/web-exporter/node_modules/puppeteer/lib/Connection.js:201:12)
at Page.pdf (/home/jon/dev/web-exporter/node_modules/puppeteer/lib/Page.js:851:39)
at /home/jon/dev/web-exporter/web_exporter.js:40:20
at <anonymous> message: 'Protocol error (Page.printToPDF): Target closed.' }
Exit code of 1.
I’ve tried various different args for chromium-browser
and page.pdf
. This application has been working generating 100s of PDFs for 6 months. In the last few days however would fail with the output above on specific pages.
The page being loaded is a react application with a 10s of small images (50-200 pixels square) embedded. The issue reproducibley fails on small number of ‘bad’ pages. Unfortunately the URL is not public.
I can open the url without issue in chrome and the same chromium-browser (non-headless), also the print to pdf works as expected.
Any help in tracking down this issue much appreciated.
Jon
Issue Analytics
- State:
- Created 5 years ago
- Reactions:13
- Comments:14 (1 by maintainers)
Top GitHub Comments
Was getting the same error on pptr v1.12.2 but was able to fix it by setting
pipe: true
when launching the browser.The issue starting popping up when trying to generate a PDF with approximately 100 various .jpgs. Using the default Websocket to connect to the browser would bail during encoding to base64. Using a pipe to connect to the browser instead seems to fix the issue of bailing during encoding.
I ran into this issue when trying to print pdfs with a company logo that had extremely large dimensions.
It was only 300kb, but it was 10,000x7000 pixels with lots of white-space
Resizing the logo to a reasonable size (ex 800x600) fixed the issue.