markdown-to-pdf icon indicating copy to clipboard operation
markdown-to-pdf copied to clipboard

Large image size breaks rendering

Open fujiiface opened this issue 5 years ago • 7 comments

Hi,

I started running into an issue while using this action that seems to be linked to the markdown-to-pdf container. Haven't really changed anything on my end other than some content in markdown and some more pictures to render. Here's the error out put:

Error: Invalid protocol: data:
    at Request.init (/node_modules/request/request.js:458:31)
    at new Request (/node_modules/request/request.js:127:8)
    at request (/node_modules/request/index.js:53:10)
    at /node_modules/request/index.js:61:12
    at Function.get (/node_modules/request/index.js:100:12)
    at /markdown-to-pdf.js:170:11
    at new Promise (<anonymous>)
    at encodeImage (/markdown-to-pdf.js:169:9)
    at ConvertImageRoutes (/markdown-to-pdf.js:111:22)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
ERROR: SyntaxError: Invalid regular expression: /data:image/png;base64,iVBORw0KGgo....
........

omitted for brevity

........YII=/: Nothing to repeat
    at new RegExp (<anonymous>)
    at ConvertImageRoutes (/markdown-to-pdf.js:112:32)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async /markdown-to-pdf.js:229:15**
Built HTML file: UserGuide.html
Built PDF file: UserGuide.pdf
Gracefully shut down image server.
(node:1) UnhandledPromiseRejectionWarning: TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded
    at /node_modules/puppeteer/lib/LifecycleWatcher.js:142:21
  -- ASYNC --
    at Frame.<anonymous> (/node_modules/puppeteer/lib/helper.js:110:27)
    at Page.goto (/node_modules/puppeteer/lib/Page.js:629:49)
    at Page.<anonymous> (/node_modules/puppeteer/lib/helper.js:111:23)
    at /markdown-to-pdf.js:159:14
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:1) 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)

I did upgrade my action to use 1.0.1 in case that was the issue but I'm still getting this consistently now.

fujiiface avatar Jul 16 '20 01:07 fujiiface

Further reference here: I'm trying to process about 35 images in one document. Total size of the images is about 4.5MB so nothing terribly big.

fujiiface avatar Jul 16 '20 01:07 fujiiface

Thanks for the detailed report, I've got a busy day today, but I'll try and have a look this evening, if not tomorrow :+1:.

BaileyJM02 avatar Jul 16 '20 09:07 BaileyJM02

Hey thanks again for taking a look. I'm able to get all the images processing now but I had to reduce their size by 50%. Also, I am still getting the listed error repeated twice but for two separate images.

fujiiface avatar Jul 16 '20 17:07 fujiiface

Hi Christopher, sorry I haven't got this sorted sooner, work has been crazy. I've just booked some time this evening to look at this, have you come across anything else over the last few days? Thanks. :smiley:

BaileyJM02 avatar Jul 28 '20 15:07 BaileyJM02

Hi Bailey thanks for the follow up. Work has been crazy over here, also. Haven't been able to push any test updates since last mentioned but there was errors still occurring in the output. It doesn't seem to stop anything at the moment but like I mentioned previously, I had to reduce the image sizes by about 50% for the action to complete successfully.

fujiiface avatar Jul 28 '20 16:07 fujiiface

Okay, well I think due to all the issues appearing, and since I wrote the original code in a rush for a personal project, I'm going to rewrite this action in Go. It should be much faster :crossed_fingers:, as I shouldn't need to create an internal webserver to encode the images or build the PDF (which should also fix the issue with the number of images and image size). Nothing should change your side, all the inputs should stay the same as I'm trying to keep it on v1 but I can't set that in stone yet. I'll keep you updated. :+1:

BaileyJM02 avatar Jul 28 '20 16:07 BaileyJM02

Hi, just thought I would drop an update in this issue for those interested... I'm still looking to rewrite this to Go, but at the moment I have a lot of personal work to do. It also may require a few workarounds with C to create the PDF from HTML due to the web engine being used. I'm exploring ways to do this - and whether I should continue to use Node, but rewrite it anyway into smaller classes. :+1:

BaileyJM02 avatar Oct 08 '20 19:10 BaileyJM02