[Bug]: Error when parsing page to PDF: ProtocolError: Protocol error (Page.printToPDF): Printing failed
See original GitHub issueBug description
I am trying to generate a pdf from a big html file with lots of images. The HTML file itself is 15MB and the total amount of images it is trying to load is ~500MB. When trying this on my local machine it works. But when trying to execute the script in a lambda or as a Docker container it outputs this error constantly.
Steps to reproduce the problem:
- Build the docker image. You can find my Dockerfile: https://gist.github.com/Sef1995/0eb0f4feead25c236e059b5afd18f75a and the code that I’m running here: https://gist.github.com/Sef1995/cc85f18aa53bf56c816a5b12cd9ec04f
- Run the docker image
- After a while the script stops and outputs the error.
Puppeteer version
13.4.0
Node.js version
14.16.1
npm version
6.14.12
What operating system are you seeing the problem on?
Linux
Relevant log output
➜ pdf-gen git:(develop) ✗ docker run pdf-gen
{"level":30,"time":1645893676687,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"starting puppeteer"}
Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank"
[0226/164117.009189:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[0226/164117.009584:ERROR:bus.cc(397)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
DevTools listening on ws://127.0.0.1:45607/devtools/browser/95372895-7025-4e0c-9b2b-d3d2aaffc70a
[0226/164117.038525:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
{"level":30,"time":1645893677087,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"done starting puppeteer"}
{"level":30,"time":1645893677087,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"new page"}
[0226/164117.104284:ERROR:sandbox_linux.cc(377)] InitializeSandbox() called with multiple threads in process gpu-process.
{"level":30,"time":1645893677153,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"done new page"}
{"level":30,"time":1645893677153,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"emulate media type"}
{"level":30,"time":1645893677154,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"done emulate media type"}
{"level":30,"time":1645893677154,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"go to page"}
{"level":30,"time":1645893702349,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"done go to page"}
{"level":30,"time":1645893702350,"pid":8,"hostname":"5200a5499cd2","name":"app-name","msg":"generate pdf"}
(node:8) UnhandledPromiseRejectionWarning: ProtocolError: Protocol error (Page.printToPDF): Printing failed
at /node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:230:24
at new Promise (<anonymous>)
at CDPSession.send (/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:226:16)
at Page.createPDFStream (/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2074:50)
at Page.pdf (/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2103:37)
at /index.js:77:20
at Generator.next (<anonymous>)
at fulfilled (/index.js:24:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:15
Top Results From Across the Web
ProtocolError: Protocol error (Page.printToPDF): Printing is not ...
PDF creation is only supported in headless mode. So this should work: const browser = await Puppeteer.launch({ headless: true });.
Read more >About to lose my mind trying to get Page.printToPDF to work ...
I feel the problem is not the chrome extension. It's the fact that chrome.debugger is only made to support Debugger methods (https://chromedevtools.github.io/ ...
Read more >Protocol error (Page.printToPDF): Target closed. - jsreport forum
I Seem to be getting this error quite a lot after updating to version 2.5.0: Protocol error (Page.printToPDF): Target closed.
Read more >Gettting Error while trying to create pdf using browserhot
printToPDF ): Show invalid printer settings error at ... at Page.pdf (/usr/lib/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:1212:43) at getOutput ...
Read more >try - Mercurial - Mozilla
setCacheEnabled should stay disabled when toggling request interception on/off (page.spec.ts)": [ "FAIL" ], "Page printing to PDF can print to PDF and save ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is working for me on my local machine ( which is Linux) but don’t work on docker was anyone able to solve this?
EDIT: Solved for me I increased the memory requests and limits of the pod and was able to render A large HTML with big tables
I am also facing the same issue with large no of data like more than 1000 table records (Rows)