alvarcarto / url-to-pdf-api

Web page PDF/PNG rendering done right. Self-hosted service for rendering receipts, invoices, or any content.
MIT License
7.01k stars 774 forks source link

Large HTML body causes Error: Navigation Timeout Exceeded: 30000ms exceeded #37

Closed kimmobrunfeldt closed 5 years ago

kimmobrunfeldt commented 6 years ago

We are using a workaround to render raw HTML. This workaround is needed to wait until all external resources are loaded. See the issue here: https://github.com/GoogleChrome/puppeteer/issues/728

I suspect that this workaround is causing errors with large HTMLs. In my tests, I found that ~2MB HTML worked, but 4MB didn't. Tried with 512MB RAM Heroku server.

richardjharris commented 6 years ago

https://bugs.chromium.org/p/chromium/issues/detail?id=69227

The max URI size in Chrome is 2MB, so a data URI exceeding that size will not work.

The current workaround I am using is to edit NetworkManager.js to allow rawResponse to be overriden by req.continue, then intercepting the first network request made by Chrome and returning my custom content. Once GoogleChrome/puppeteer#1020 is complete you will be able to do this without editing NetworkManager.js :)

kimmobrunfeldt commented 6 years ago

As an update, Puppeteer was upgraded to 1.6.0 but the issue still remains :/ One workaround could be to save the incodming HTML into a file as mentioned here: https://github.com/GoogleChrome/puppeteer/issues/728

kjagiello commented 5 years ago

Fixed in #103