johntitus / node-horseman

Run PhantomJS from Node
MIT License
1.45k stars 125 forks source link

Failed to load URL happening with `openTab` but not `open` #309

Open bradleygore opened 7 years ago

bradleygore commented 7 years ago

I know there are other open issues for the infamous Failed to load URL issue, however I'm not 100% sure this is or isn't related as what I'm seeing appears to be specifically related to opening some specific URLs in a new tab vs an existing window. I have a simple test script, using a URL accessible by anyone, provided in this gist.

Here are my specs:

OS Sierra 10.12.6

→ phantomjs -v
2.1.1

→ npm ls | grep horseman
├─┬ node-horseman@3.3.0

→ node -v
v6.10.0

→ npm -v
3.10.10

Example output when running the script in the gist above:

No Tab

→ DEBUG=horseman node ./horsemanTest.js
  horseman using PhantomJS from phantomjs module +0ms
  horseman .setup() creating phantom instance 1 +55ms
  horseman phantom created +759ms
  horseman phantom version 2.1.1 +16ms
  horseman page created +8ms
  horseman phantomjs onLoadFinished triggered success NaN +7ms
  horseman .open() http://techinfo.honda.com/rjanisis/content/rjxa_isisviewer_ui.aspx?v=&m=T2AD&k=pubs/sm/1/2/Contents/enu/61T2AD/GEN/SCT/SC/SYS/G006389_enu/web/html/G006389_enu&p=SM&t=H&model=ACCORD&year=2017&trim=&keyword=&path=&dbkey=61T2AD_G006389_enu&country=1&lang=0 +5ms
  horseman phantomjs onLoadFinished triggered success 1 +2s
  horseman .wait() 500 +4ms
  horseman .screenshot() ./horsemanReport.png +502ms
  horseman .close(). +4ms

With Tab

→ DEBUG=horseman node ./horsemanTest.js --tab
  horseman using PhantomJS from phantomjs module +0ms
  horseman .setup() creating phantom instance 1 +55ms
  horseman phantom created +764ms
  horseman phantom version 2.1.1 +16ms
  horseman page created +8ms
  horseman phantomjs onLoadFinished triggered success NaN +7ms
  horseman page created +8ms
  horseman phantomjs onLoadFinished triggered fail 1 +299ms
ERROR:  { Error: Failed to load url
    at checkStatus (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-horseman/lib/index.js:292:16)
    at tryCatcher (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/bluebird/js/release/method.js:39:29)
    at Object.loadFinishedSetup [as onLoadFinished] (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-horseman/lib/index.js:290:43)
    at /Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-phantom-simple/node-phantom-simple.js:636:30
    at Array.forEach (native)
    at IncomingMessage.<anonymous> (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-phantom-simple/node-phantom-simple.js:617:17)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
  cause:
   Error: Failed to load url
       at checkStatus (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-horseman/lib/index.js:292:16)
       at tryCatcher (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/bluebird/js/release/util.js:16:23)
       at Function.Promise.attempt.Promise.try (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/bluebird/js/release/method.js:39:29)
       at Object.loadFinishedSetup [as onLoadFinished] (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-horseman/lib/index.js:290:43)
       at /Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-phantom-simple/node-phantom-simple.js:636:30
       at Array.forEach (native)
       at IncomingMessage.<anonymous> (/Users/bradley/Documents/projects/client/svc-lane-eadvisor/slea-webapps/web-scrapers/scrapers/honda-maint/node_modules/node-phantom-simple/node-phantom-simple.js:617:17)
       at emitNone (events.js:91:20)
       at IncomingMessage.emit (events.js:185:7)
       at endReadableNT (_stream_readable.js:974:12)
       at _combinedTickCallback (internal/process/next_tick.js:74:11)
       at process._tickCallback (internal/process/next_tick.js:98:9),
  isOperational: true }
  horseman .close(). +4ms