node-html-pdf icon indicating copy to clipboard operation
node-html-pdf copied to clipboard

Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.

Open commander007 opened this issue 9 years ago • 17 comments

throws this error while genrating pdf using node.js on sails framework. Previously the same code was working fine, but have been getting this error since last 3 days.

var pdf = require('html-pdf');

var options = { "format":"Letter" , "orientation": "portrait", "footer":{ "height":"15mm" }, "quality": "75", "type":"pdf", "timeout":60000 }; var file = 'assets/templates/invoice.ejs' var html = ejs.render(fs.readFileSync(file, 'utf8'),{ 'data': params.data }); pdf.create(html,options).toFile('././invoice/' + params.title + '.pdf', function(err, result) { if (err) { return console.log("err", err); } if (callback != undefined) { return callback(null, { 'fileName':params.title + '.pdf'}); } return res.json({ 'fileName':params.title + '.pdf'}); });

I have already checked all the parameters and data being passed.

commander007 avatar Jan 20 '17 09:01 commander007

A quick workaround (Not a fix) I ended up doing is extending the timeout in the options to 60 seconds. when executing the pdf generation to get rid of this issue.

RabeaWahab avatar Oct 09 '17 16:10 RabeaWahab

I have the same issue when I run my code in a docker container. Outside of it, everything runs fine. I'm going to try to increase the timeout, but that seems like a workaround like @RabeaWahab said

Well: it does not fix the problem, I'll have to dig deeper

RDeluxe avatar Oct 23 '17 19:10 RDeluxe

Getting same error when using in aws Lambda function.

ioanniswd avatar Jan 30 '18 13:01 ioanniswd

Same here.

Samuel-Montoya avatar Mar 30 '18 21:03 Samuel-Montoya

Ditto. Anyone have any insight into this problem?

bndnio avatar Apr 06 '18 06:04 bndnio

I do have also the same problem using this library in Cloud Functions

JohneSchwoopf avatar Apr 06 '18 07:04 JohneSchwoopf

I ended up getting this fixed. You have to set the timeout parameter to a high value. My laptop ended up being too slow, resulting in it timing out with this error. Hopefully this helps!

pdf.create(html, { orientation: 'landscape', type: 'pdf', timeout: '100000' })

Samuel-Montoya avatar Apr 06 '18 14:04 Samuel-Montoya

I extended the timeout. Then the pdf could be generated but image from img html tag display blue question mark box. So i think extend the timeout could not really fix this problem.

dqhung215 avatar Oct 27 '19 14:10 dqhung215

2020 and I have the same mistake! There are times that it generates the pdf very fast, with a certain time of 3 seconds, and there are times that it is eternally processing, until the 120000ms timeout that I put has burst. Someone solved it?

AlisonGalvani avatar Jul 10 '20 13:07 AlisonGalvani

Hello, i was faced with this error on the server(DMZ) but not locally on my machine,

Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.

And after much research and debugging, all i needed to do was to comment out the link tag containing an attribute href=fonts.googleapis.com in my html

And it worked just fine afterwards.

Olashile-A avatar Aug 07 '20 09:08 Olashile-A

This seems to be a problem with the html, my problem was that I had an image source linked to a deleted image in a server and that was what caused the time out, I solved it by putting the image in the server's route and that was it, I hope this to be useful to someone

UCuevas avatar Aug 14 '20 02:08 UCuevas

Hello, i was faced with this error on the server(DMZ) but not locally on my machine,

Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.

And after much research and debugging, all i needed to do was to comment out the link tag containing an attribute href=fonts.googleapis.com in my html

And it worked just fine afterwards.

This works for me. Thanks.

Dwigth avatar Jan 20 '21 21:01 Dwigth

This seems to be a problem with the html, my problem was that I had an image source linked to a deleted image in a server and that was what caused the time out, I solved it by putting the image in the server's route and that was it, I hope this to be useful to someone

This worked for me! Thanks a lot.

hassanmehdi98 avatar Jul 28 '21 12:07 hassanmehdi98

there is some problem in this library when loading the images, even being in the aws s3 the pdf takes a very long time to load. When images are removed from html the pdf loads very fast.

yan-vidal avatar Oct 28 '21 17:10 yan-vidal

Hello, i was faced with this error on the server(DMZ) but not locally on my machine,

Error: html-pdf: PDF generation timeout. Phantom.js script did not exit.

And after much research and debugging, all i needed to do was to comment out the link tag containing an attribute href=fonts.googleapis.com in my html

And it worked just fine afterwards.

Bro this solved mine too. I changed the image source and haven't changed it on the html template. So the "html-pdf" module keep waiting the image, to render, as it don't exist, so it will never render, ocorruring in a time out error.

tavioribeiro avatar Jan 24 '22 16:01 tavioribeiro

Same issue here, would try extending the timeout, image is inside the server and no fonts.googleapis

ezewer avatar Apr 06 '22 06:04 ezewer

same issue image tag was loading huge data.. i removed and it worked

juveria-osv avatar Dec 07 '22 04:12 juveria-osv