Skip to content
This repository has been archived by the owner on Mar 22, 2018. It is now read-only.

Error: ENOENT, no such file or directory '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png' #54

Open
vbauer opened this issue Mar 20, 2014 · 7 comments

Comments

@vbauer
Copy link

vbauer commented Mar 20, 2014

It looks like we have a problem with file cache:

Sending image in response
Error: ENOENT, stat '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png'
{ [Error: ENOENT, no such file or directory '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png']
  errno: 34,
  code: 'ENOENT',
  path: '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png',
  syscall: 'unlink' }
Request for http://https://www.google.ru/url?sa=t,https://sites.google.com/?hl=ru - Rasterizing it
@thomastraum
Copy link

I am having the exact same problem, any pointers?

@vbauer
Copy link
Author

vbauer commented Apr 15, 2014

Nope, I'm still waiting any news about it from author..

@gcrumb
Copy link

gcrumb commented Apr 21, 2014

Got bitten by the same problem. Here's what I've found:

The problem originates in the phantomjs renderer, I think. If you manually call the render service with an URL that results in this error, you'll see:

curl -H "url: https://bogus.url" -H "filename: file.png" http://localhost:3001/
Error: Url returned status fail

But in spite of sending a failure message, the server doesn't return an error status (e.g. 500), so route/index.js doesn't trap this, and goes ahead and adds the filename to the collection. But when it tries to send the non-existent file, you see the above exception.

Here's a patch that will at least properly trap the error:

diff --git a/routes/index.js b/routes/index.js
index 4cc6d59..c992dd2 100644
--- a/routes/index.js
+++ b/routes/index.js
@@ -11,7 +11,7 @@ module.exports = function(app, useCors) {
   // routes
   app.get('/', function(req, res, next) {
     if (!req.param('url', false)) {
-      return res.redirect('/usage.html');
+      return res.redirect('usage.html');
     }
 
     var url = utils.url(req.param('url'));
@@ -75,7 +75,11 @@ module.exports = function(app, useCors) {
   }
 
   var callRasterizer = function(rasterizerOptions, callback) {
     request.get(rasterizerOptions, function(error, response, body) {
+                       if (body.match(/Error:/)){
+                               return callback(new Error(body));
+                       }
       if (error || response.statusCode != 200) {
         console.log('Error while requesting the rasterizer: %s', error.message);
         rasterizerService.restartService();
@@ -107,10 +111,14 @@ module.exports = function(app, useCors) {
       res.setHeader("Access-Control-Allow-Origin", "*");
       res.setHeader("Access-Control-Expose-Headers", "Content-Type");
     }
+               if (!fs.existsSync(imagePath)){
+                               console.log("File does not exist! ", imagePath);
+                               return;
+               }
     res.sendfile(imagePath, function(err) {
       fileCleanerService.addFile(imagePath);
       callback(err);
     });
   }
 

The proper thing to do, of course is to get the rendering service to return an appropriate HTTP response status.

@slorber
Copy link

slorber commented Dec 11, 2014

I have the same problem here.

It seems it happens mostly for bad URLs, but also for HTTPS protocol (not always however).

For exemple I have some cases where only the HTTPS version fails:

OK: http://localhost:3000/?url=http://en.wikipedia.org/wiki/User_agent
KO: http://localhost:3000/?url=https://en.wikipedia.org/wiki/User_agent

OK: http://localhost:3000/?url=http://leverich.github.io/swiftislikescala/
KO: http://localhost:3000/?url=https://leverich.github.io/swiftislikescala/

Yes according to what I see, PhantomJS returns a status code 200 with body Error: Url returned status fail\n

Any solution?

@vbauer
Copy link
Author

vbauer commented Dec 11, 2014

To solve this problem, I built my own lunar lander, with blackjack and hookers: https://github.com/vbauer/manet

@slorber
Copy link

slorber commented Dec 11, 2014

@vbauer thanks, glad to know. I may switch to your service if I can't solve my problems with actual server.

For into those having problems with HTTPS I think this is because of this PhantomJS problem:
http://stackoverflow.com/questions/12021578/phantomjs-failing-to-open-https-site

@candu
Copy link

candu commented Jun 23, 2017

This was fixed for me by upgrading to phantomjs 2.1.1 - haven't investigated enough to know why. (I was previously on phantomjs 1.9.8; ran both times under node v6.7.0.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants