macbre / phantomas

Headless Chromium-based web performance metrics collector and monitoring tool
https://www.npmjs.com/package/phantomas
BSD 2-Clause "Simplified" License
2.25k stars 141 forks source link

Fulfilled promise with error code 1 #382

Closed stefanjudis closed 9 years ago

stefanjudis commented 9 years ago

Hey @macbre,

I'm fighting with this issue here

https://github.com/stefanjudis/grunt-phantomas/issues/116#issuecomment-52307355

I can kind of reproduce by running

$ phantomas http://www.dailymail.co.uk/news/article-2639783/Father-childhood-pal-turned-model-virginiller-claimed-women-mean-cruless-creatures-says.html --reporter json
FAIL: 1

$ phantomas --version
phantomas v1.5.0

And this leads two to questions. Why 1? Never saw this one and it's not defined.

https://github.com/macbre/phantomas/blob/devel/core/phantomas.js#L24

And additionally phantomas is fulfilling the promise with status 1 which is not correct. It should be rejected, or am I wrong?

So this condition here

https://github.com/macbre/phantomas/blob/devel/lib/index.js#L174

needs to be adjusted?

Thanks a lot. :)

macbre commented 9 years ago

@stefanjudis, thanks for the bug report.

I run phantomas in verbose mode and get lots of JS errors and page failed to load and phantomas failed to generate a report.

phantomas.js "http://www.dailymail.co.uk/news/article-2639783/Father-childhood-pal-turned-model-virginiller-claimed-women-mean-cruless-creatures-says.html" --verbose 2>&1 | grep TypeError
17:49:50.114 TypeError: Attempted to assign to readonly property.
17:49:50.311 TypeError: 'undefined' is not an object (evaluating 'DM.ComScore.off = false')
17:49:50.312 TypeError: 'undefined' is not an object (evaluating 'DM.ComScore.dm')
17:49:50.313 TypeError: 'undefined' is not an object (evaluating 'DM.pageEvents.listen')
(...)
17:49:53.058 TypeError: 'undefined' is not an object (evaluating 'adverts.addToArray')
17:49:53.059 TypeError: 'undefined' is not an object (evaluating 'adverts.addToArray')
17:49:53.061 TypeError: 'undefined' is not an object (evaluating 'adverts.addToArray')

The last thing I get from phantomas is:

17:49:27.829 contentLength missing: {"url":"https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.pl.IQT_H-XARD0.O/m=client/exm=interactivepost,plusone/rt=j/sv=1/d=1/ed=1/am=AQ/rs=AItRSTOehY_gbS6mW1A9Ubu6l-7UoqLBCw/cb=gapi.loaded_1","bodySize":60636}
17:49:27.830 Event recv emitted
17:49:27.850 Event jserror emitted
17:49:27.851 ReferenceError: Can't find variable: AND
17:49:27.852 Backtrace: unknown fn: http://www.dailymail.co.uk/news/article-2639783/Father-childhood-pal-turned-model-virgin-killer-claimed-women-mean-cruel-heartless-creatures-says.html @ 6628

Running in --gecko mode works (timeout setting needs to be adjusted). It must be PhantomJS dying unexpectedly.

stefanjudis commented 9 years ago

Okay. :)

But then the promise should be rejected correctly?

macbre commented 9 years ago

PhantomJS dies with a core dump.

ulimit -c unlimited
phantomas ...
gdb phantomjs core
macbre commented 9 years ago

I've improved "null" exit codes handling a bit to detect PhantomJS core dumps:

10:20:41.287 Event domQuery emitted
10:20:41.287 DOM query: by tag name - "span" (using getElementsByTagName)
10:20:41.321 Event jserror emitted
10:20:41.322 TypeError: 'undefined' is not an object (evaluating 'adverts.addToArray')
10:20:41.323 Backtrace: unknown fn: http://www.dailymail.co.uk/news/article-2639783/Father-childhood-pal-turned-model-virgin-killer-claimed-women-mean-cruel-heartless-creatures-says.html @ 3883
Debug: PhantomJS has crashed. Please read the crash reporting guide at https://github.com/ariya/phantomjs/wiki/Crash-Reporting and file a bug report at https://github.com/ariya/phantomjs/issues/new with the crash dump file attached: /tmp/643a9f73-9762-a8b6-16981a54-6a1937a0.dmp
phantomas: (255) Engine crashed unexpectedly
macbre@debian:~/github/phantomas$ echo $?
255

Promise will be rejected with status / exit code 255. The same exit code will be returned by phantomas "binary".

stefanjudis commented 9 years ago

Thanks. :bowtie: