node-horseman: `Unhandled reject Error: Failed to load url`

@minhchu has reported a bug they are facing where an Unhandled rejection Error: Failed to load url is thrown. This is similar to #180 however the case is not due to SlimerJS in which #180 is specifically for. This new issue will track the new case @minhchu is facing.

The test case which can reproduce the issue is below:

var Horseman = require('node-horseman');
var horseman = new Horseman();

horseman
  .userAgent('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0')
  .open('https://www.google.com/search?site=&tbm=isch&source=hp&biw=1366&bih=640&q=moon')
  .screenshot('example.jpg')
  .close();

The output is below:

  horseman using PhantomJS from $PATH +0ms
  horseman .setup() creating phantom instance on 12406 +4ms
  horseman phantom created +673ms
  horseman phantom version 2.1.1 +17ms
  horseman page created +11ms
  horseman phantomjs onLoadFinished triggered +13ms success NaN
  horseman injected jQuery +46ms
  horseman .userAgent() set +20ms Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
  horseman .open() +1ms https://www.google.com/search?site=&tbm=isch&source=hp&biw=1366&bih=640&q=moon
  horseman phantomjs onLoadFinished triggered +899ms success 1
  horseman phantomjs onLoadFinished triggered +103ms fail 2
  horseman injected jQuery +1ms
  horseman .close(). +4ms
Unhandled rejection Error: Failed to load url
    at checkStatus (/Users/user/Projects/node_modules/node-horseman/lib/index.js:276:16)
    at tryCatcher (/Users/user/Projects/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/user/Projects/node_modules/bluebird/js/release/method.js:39:29)
    at Object.loadFinishedSetup [as onLoadFinished] (/Users/user/Projects/node_modules/node-horseman/lib/index.js:274:43)
    at /Users/user/Projects/node_modules/node-phantom-simple/node-phantom-simple.js:636:30
    at Array.forEach (native)
    at IncomingMessage.<anonymous> (/Users/user/Projects/node_modules/node-phantom-simple/node-phantom-simple.js:617:17)
    at emitNone (events.js:72:20)
    at IncomingMessage.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:913:12)
    at nextTickCallbackWith2Args (node.js:442:9)
    at process._tickCallback (node.js:356:17)

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 7
  • Comments: 62 (9 by maintainers)

Most upvoted comments

For me it was SSL Handshake was causing error, i get it figure out using following event handler.

For same i used ignoreSSLErrors: true while creating horseman object, it resolves the issue.

horseman.on('resourceError',function(err)  {
        console.log(err);
      });

I encountered the same issue, in my case adding a .wait(3000) before .click helped.

Same issue here. Works intermittently, but mostly it doesn’t. Makes horseman unusable for /me. 😢

@geek-caroline This happens to me if I do not specify the protocol, i.e. www.google.com will not work, but http://www.google.com works just fine

I try to run the example at node-horseman/examples/links.js and it gives me the ‘Failed to get url’ error.