Open vbauer opened 10 years ago
I am having the exact same problem, any pointers?
Nope, I'm still waiting any news about it from author..
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.
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?
To solve this problem, I built my own lunar lander, with blackjack and hookers: https://github.com/vbauer/manet
@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
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.)
It looks like we have a problem with file cache: