brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 285 forks source link

[Error: PhantomJS exited with return value 2] #123

Open thomasspiesser opened 9 years ago

thomasspiesser commented 9 years ago

Hey, I'm trying to create a pdf from html with the following code

webshot('<html><body>solala</body></html>', 'test.pdf', {siteType: 'html'}, function(error) {
  if ( error ) return console.log( error );
  fs.readFile(filename, function(err, data) {
    if (err) return console.log(err);
    console.log(data);
  });
});

which returns the following error [Error: PhantomJS exited with return value 2]. I have spend a day and a half trying to figure out what this error means (w/o luck so far). versions, webshot: 0.16.0 but also tried 0.15.4, phantom is installed via npm, version phantomjs: 1.9.9. Any help would be very much appreciated, thanks!

holographix commented 8 years ago

I got a [ Error: PhantomJS exited with return value 1 ] instead. It happens when I put a lot a of webshot calls one after the other in a for loop. FYI, what I'm trying to achieve here, is to generate a PDF out of many webshots of d3 line charts. Anyway, when I got a small amount of calls, let's say 10/20, everything plays out smooth, but when we get to 100 or more, then it freaks out and start to output this error message.

I'll let you know I stumble upon a solution. I got the feeling it's some memory related problem anyway.

rudza commented 8 years ago

I got the same error. @thomasspiesser Did you managed to fix this? :)

thomasspiesser commented 8 years ago

fixed this? no, but i got it working in the end by not using webshot and calling phantom directly instead. i describe the workflow here

cubicuboctahedron commented 8 years ago

Using phantomjs-2.1.1 and phantomPath: require('phantomjs').path webshot option solved this issue for me

bsbechtel commented 8 years ago

I had this issue as well. I use mup to deploy my meteor project on DO, and assigned my "phantomPath": "/usr/bin/phantomjs"which is where mup installs phantomjs (technically the path is a symlink). Hopefully this is helpful to others who have this issue.

rygim commented 8 years ago

I got the [ Error: PhantomJS exited with return value 1 ] message.

It ended up that I was not correctly setting the url to what I wanted. I put a console.log statement here (https://github.com/brenden/node-webshot/blob/master/lib/webshot.js#L201) and caught my error. Hopefully this is something else to check for people having trouble. The error messages are not explicit at all.

alvara commented 8 years ago

Thank you @bsbechtel, I was having this same problem for past day and a half.

I added phantomPath: "/usr/bin/phantomjs" to my webshot options, and also made sure that mup.js had the 'setupPhantom: true'. I am using phantomjs 1.9.8 and meteor 1.4.1.2 .

Finally can generate pdfs properly.

IDCOLL commented 7 years ago

WOW, eventually stumbled onto this, phantomPath: "/usr/bin/phantomjs" is the way to go to make webshot work. Thanks to @bsbechtel