stefanjudis / grunt-phantomas

Grunt plugin wrapping phantomas to measure frontend performance
MIT License
285 stars 25 forks source link

Add `--ignore-ssl-errors` option #158

Closed Wilto closed 9 years ago

Wilto commented 9 years ago

Running into the following using grunt-phantomas:

PHANTOMAS EXECUTION(S) STARTED.
Executing phantomas ( 3 times ) with following parameters:
{}
>> 3 Phantomas execution(s) done -> checking results:
>> Phantomas execution not successful -> 254
>> Phantomas execution not successful -> 254
>> Phantomas execution not successful -> 254

Using Phantomas itself to test https://responsiveimages.org gives me the same issue, unless I pass along --ignore-ssl-errors=true—then everything works as expected. Would it be possible to expose --ignore-ssl-errors (and possibly the --ssl-protocol options) in the Gruntfile configuration?

stefanjudis commented 9 years ago

@Wilto

Hey hey,

isn't that what you're looking for?

https://github.com/stefanjudis/grunt-phantomas#optionsoptions https://github.com/stefanjudis/grunt-phantomas#phantomas-options

Wilto commented 9 years ago

I’ve been tinkering with that, but it doesn’t seem to be doing the job:

module.exports = function(grunt) {
    grunt.loadNpmTasks('grunt-phantomas');

    grunt.config("phantomas", {
        landing: {
            options: {
                indexPath: './phantomas/',
                url: 'https://responsiveimages.org',
                numberOfRuns: 3,
                buildUi: true,
                options : {
                    "ignore-ssl-errors": true,
                    "ssl-protocol": "any"
                }
            }
        }
    });
};

The day is getting a little long, so it’s entirely possible I’m doing something dumb here.

stefanjudis commented 9 years ago

Hmm... It's handed directly to phantomas itself.

https://github.com/stefanjudis/grunt-phantomas/blob/master/tasks/lib/phantomas.js#L307-L329

Let me play around with this for a few minutes. :)

Wilto commented 9 years ago

Appreciate it! For what it’s worth, phantomas https://responsiveimages.org --ignore-ssl-errors=true is going through without a hitch.

stefanjudis commented 9 years ago

@Wilto

Can you run

./node_modules/.bin/phantomas https://responsiveimages.org --ignore-ssl-errors=true --debug

from the project root, where you gruntfile is located? It's also failing here.

> ./node_modules/.bin/phantomas --version                                                                   [23:06:03]
phantomas v1.10.0

What global version of phantomas do you have installed?

stefanjudis commented 9 years ago

@Wilto

also the output of

DEBUG=phantomas* grunt phantomas

might help.

But I'm pretty sure, it's not a problem of grunt-phantomas itself.

cc. @macbre

Wilto commented 9 years ago
wilto@sphairai: ~/Sites/[redacted]/node_modules/grunt-phantomas/node_modules/phantomas/bin on perfbudget-redux[!]
$ node phantomas.js https://responsiveimages.org --ignore-ssl-errors=true --ssl-protocol=any --debug

This goes through just fine; same with my global Phantomas. Just needs the --ssl-protocol=any on it.

I’m logging the results as passed to Phantomas by the plugin, and I think that looks okay? It isn’t giving me verbose either, though—either I’m donking up the syntax somehow, or the options aren’t being passed along the way I’d expect:

Running "phantomas:landing" (phantomas) task

PHANTOMAS EXECUTION(S) STARTED.
{"verbose":true,"ignore-ssl-errors":true,"ssl-protocol":"any"}
>> 3 Phantomas execution(s) done -> checking results:
>> Phantomas execution not successful -> 252
>> Phantomas execution not successful -> 252
>> Phantomas execution not successful -> 252

What global version of phantomas do you have installed?

phantomas v1.10.2 inside grunt-phantomas and globally; no difference there.

stefanjudis commented 9 years ago

@Wilto

As said can you paste the output of this also?

DEBUG=phantomas* grunt phantomas

Wilto commented 9 years ago

wilto@sphairai: ~/Sites/[redacted]/source on perfbudget-redux[!?]
$ DEBUG=phantomas* grunt phantomas
Running "phantomas:landing" (phantomas) task

PHANTOMAS EXECUTION(S) STARTED.
{"ignore-ssl-errors":true,"ssl-protocol":"any"}
  phantomas nodejs v0.10.28 +0ms
  phantomas phantomas v1.10.2 installed in /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas +1ms
  phantomas URL: <https://responsiveimages.org> +0ms
  phantomas Options: {"ignore-ssl-errors":true,"ssl-protocol":"any","film-strip":true,"film-strip-dir":"phantomas/images/1433352718215"} +0ms
  phantomas Temporary directory: /var/folders/8s/tbqt16ps181cy0_lm9v_9nb00000gn/T//phantomas/43847a07-fb2f-4eda-9aa0-713e2fc8cbd1/ +2ms
  phantomas:engines Engine "webkit": PhantomJS v1.9.8 installed in /Users/wilto/Sites/[redacted]/source/node_modules/phantomjs/lib/phantom/bin/phantomjs +3ms
  phantomas:engines Engine "gecko": SlimerJS v0.9.5 installed in /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas/node_modules/slimerjs/lib/slimer/slimerjs +7ms
  phantomas:engines Running /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas/scripts/phantomas.js (using PhantomJS) +0ms
  phantomas:engines Passing phantomas options: {"film-strip":true,"film-strip-dir":"phantomas/images/1433352718215","url":"https://responsiveimages.org","user-agent":"phantomas/1.10.2 (PhantomJS/1.9.8; darwin x64)"} +0ms
  phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=false"] +0ms
  phantomas Spawned with pid #2133 +4ms
  phantomas:ipc filmStrip: ["phantomas/images/1433352718215/screenshot-2015-06-03T17-31-59-42.png",42] +1s
  phantomas:ipc progress: [10,10] +15ms
  phantomas:progress 10% (+10%) +0ms
  phantomas:ipc metric: ["timeToFirstByte",0] +131ms
  phantomas:ipc metric: ["timeToLastByte",205] +0ms
  phantomas:ipc metric: ["statusCodesTrail",""] +0ms
  phantomas:ipc milestone: ["responseEnd"] +0ms
  phantomas:ipc filmStrip: ["phantomas/images/1433352718215/screenshot-2015-06-03T17-31-59-189.png",189] +122ms
  phantomas:ipc exit: [254,"Page loading failed"] +1ms
  phantomas:results Process returned code #254 +24ms
  phantomas:results Error when parsing JSON (SyntaxError: Unexpected end of input) +0ms
  phantomas:results Rejecting a promise with 254 exit code +2ms
  phantomas nodejs v0.10.28 +1ms
  phantomas phantomas v1.10.2 installed in /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas +0ms
  phantomas URL: <https://responsiveimages.org> +0ms
  phantomas Options: {"ignore-ssl-errors":true,"ssl-protocol":"any"} +0ms
  phantomas Temporary directory: /var/folders/8s/tbqt16ps181cy0_lm9v_9nb00000gn/T//phantomas/a1816c9f-db87-4f52-b371-34a319f12827/ +0ms
  phantomas:engines Engine "webkit": PhantomJS v1.9.8 installed in /Users/wilto/Sites/[redacted]/source/node_modules/phantomjs/lib/phantom/bin/phantomjs +0ms
  phantomas:engines Engine "gecko": SlimerJS v0.9.5 installed in /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas/node_modules/slimerjs/lib/slimer/slimerjs +0ms
  phantomas:engines Running /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas/scripts/phantomas.js (using PhantomJS) +0ms
  phantomas:engines Passing phantomas options: {"url":"https://responsiveimages.org","user-agent":"phantomas/1.10.2 (PhantomJS/1.9.8; darwin x64)"} +0ms
  phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=false"] +0ms
  phantomas Spawned with pid #2134 +3ms
  phantomas:ipc progress: [10,10] +927ms
  phantomas:progress 10% (+10%) +0ms
  phantomas:ipc metric: ["timeToFirstByte",0] +5ms
  phantomas:ipc metric: ["timeToLastByte",55] +1ms
  phantomas:ipc metric: ["statusCodesTrail",""] +0ms
  phantomas:ipc milestone: ["responseEnd"] +0ms
  phantomas:ipc exit: [254,"Page loading failed"] +1ms
  phantomas:results Process returned code #254 +20ms
  phantomas:results Error when parsing JSON (SyntaxError: Unexpected end of input) +1ms
  phantomas:results Rejecting a promise with 254 exit code +0ms
  phantomas nodejs v0.10.28 +0ms
  phantomas phantomas v1.10.2 installed in /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas +0ms
  phantomas URL: <https://responsiveimages.org> +0ms
  phantomas Options: {"ignore-ssl-errors":true,"ssl-protocol":"any"} +0ms
  phantomas Temporary directory: /var/folders/8s/tbqt16ps181cy0_lm9v_9nb00000gn/T//phantomas/a25772c2-5935-43d1-96be-43ffdd8360aa/ +0ms
  phantomas:engines Engine "webkit": PhantomJS v1.9.8 installed in /Users/wilto/Sites/[redacted]/source/node_modules/phantomjs/lib/phantom/bin/phantomjs +1ms
  phantomas:engines Engine "gecko": SlimerJS v0.9.5 installed in /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas/node_modules/slimerjs/lib/slimer/slimerjs +0ms
  phantomas:engines Running /Users/wilto/Sites/[redacted]/source/node_modules/grunt-phantomas/node_modules/phantomas/scripts/phantomas.js (using PhantomJS) +0ms
  phantomas:engines Passing phantomas options: {"url":"https://responsiveimages.org","user-agent":"phantomas/1.10.2 (PhantomJS/1.9.8; darwin x64)"} +0ms
  phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=false"] +0ms
  phantomas Spawned with pid #2135 +2ms
  phantomas:ipc progress: [10,10] +941ms
  phantomas:progress 10% (+10%) +1ms
  phantomas:ipc metric: ["timeToFirstByte",0] +24ms
  phantomas:ipc metric: ["timeToLastByte",75] +0ms
  phantomas:ipc metric: ["statusCodesTrail",""] +1ms
  phantomas:ipc milestone: ["responseEnd"] +0ms
  phantomas:ipc exit: [254,"Page loading failed"] +1ms
  phantomas:results Process returned code #254 +21ms
  phantomas:results Error when parsing JSON (SyntaxError: Unexpected end of input) +0ms
  phantomas:results Rejecting a promise with 254 exit code +0ms
>> 3 Phantomas execution(s) done -> checking results:
>> Phantomas execution not successful -> 254
>> Phantomas execution not successful -> 254
>> Phantomas execution not successful -> 254

WRITING RESULT FILES.
>> SOMETHING WENT WRONG...
>> No run was successful.
stefanjudis commented 9 years ago

@Wilto

So CLI options are handed in correctly, right?

phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=false"] +0ms

So we might open up an issues at macbre/phantomas. Not much I can do here.

interestingly it's failing on both ways for me.

stefan @ stefan-mac: ~/Sites/grunt-phantomas master (╯°□°)╯
> DEBUG=phantomas* ./node_modules/phantomas/bin/phantomas.js https://responsiveimages.org --ignore-ssl-errors=true --ssl-protocol=any
  phantomas:cli Preparing 1 run(s)... +0ms
  phantomas nodejs v0.12.0 +3ms
  phantomas phantomas v1.10.0 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas +1ms
  phantomas URL: <https://responsiveimages.org> +0ms
  phantomas Options: {"version":false,"V":false,"help":false,"h":false,"colors":false,"disable-js":false,"no-externals":false,"progress":false,"silent":false,"spy-eval":false,"verbose":false,"v":false,"scroll":false,"film-strip":false,"analyze-css":false,"page-source":false,"ignore-ssl-errors":"true","ssl-protocol":"any","reporter":"plain","R":"plain","format":"plain","timeout":15} +0ms
  phantomas Temporary directory: /var/folders/03/cgg2bwfd6j92tfllylt5b91m0000gn/T//phantomas/200053de-698b-4d69-a33e-5ae1ff7a8376/ +3ms
  phantomas:engines Engine "webkit": PhantomJS v1.9.8 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/phantomjs/lib/phantom/bin/phantomjs +2ms
  phantomas:engines Engine "gecko": SlimerJS v0.9.5 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/slimerjs/lib/slimer/slimerjs +3ms
  phantomas:engines Running /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/scripts/phantomas.js (using PhantomJS) +1ms
  phantomas:engines Passing phantomas options: {"version":false,"V":false,"help":false,"h":false,"colors":false,"disable-js":false,"no-externals":false,"progress":false,"silent":false,"spy-eval":false,"verbose":false,"v":false,"scroll":false,"film-strip":false,"analyze-css":false,"page-source":false,"reporter":"plain","R":"plain","format":"plain","timeout":15,"url":"https://responsiveimages.org","user-agent":"phantomas/1.10.0 (PhantomJS/1.9.8; darwin x64)"} +0ms
  phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=false"] +0ms
  phantomas Spawned with pid #5008 +5ms
  phantomas:ipc progress: [10,10] +1s
  phantomas:progress 10% (+10%) +0ms
  phantomas:ipc metric: ["timeToFirstByte",0] +43ms
  phantomas:ipc metric: ["timeToLastByte",95] +0ms
  phantomas:ipc metric: ["statusCodesTrail",""] +0ms
  phantomas:ipc milestone: ["responseEnd"] +0ms
  phantomas:ipc exit: [254,"Page loading failed"] +1ms
phantomas: (254) Page loading failed
  phantomas:results Process returned code #254 +23ms
  phantomas:results Error when parsing JSON (SyntaxError: Unexpected end of input) +0ms
  phantomas:runs err: 254 +1ms
  phantomas:runs results [1]: [null] +0ms
  phantomas:runs Exiting with code #254 +0ms
FAIL: 254

stefan @ stefan-mac: ~/Sites/grunt-phantomas master (╯°□°)╯
> DEBUG=phantomas* ./node_modules/phantomas/bin/phantomas.js --version
phantomas v1.10.0

and

stefan @ stefan-mac: ~/Sites/grunt-phantomas master (╯°□°)╯
> DEBUG=phantomas* grunt phantomas
Running "phantomas:grunt" (phantomas) task

PHANTOMAS EXECUTION(S) STARTED.
  phantomas nodejs v0.12.0 +0ms
  phantomas phantomas v1.10.0 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas +1ms
  phantomas URL: <https://responsiveimages.org> +0ms
  phantomas Options: {"ignore-ssl-errors":true,"ssl-protocol":"any","debug":true,"film-strip":true,"film-strip-dir":"phantomas/images/1433360349885"} +0ms
  phantomas Temporary directory: /var/folders/03/cgg2bwfd6j92tfllylt5b91m0000gn/T//phantomas/8a835995-5112-4e7f-ad5d-c22e0aac29a9/ +2ms
  phantomas:engines Engine "webkit": PhantomJS v1.9.8 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/phantomjs/lib/phantom/bin/phantomjs +5ms
  phantomas:engines Engine "gecko": SlimerJS v0.9.5 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/slimerjs/lib/slimer/slimerjs +6ms
  phantomas:engines Running /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/scripts/phantomas.js (using PhantomJS) +0ms
  phantomas:engines Passing phantomas options: {"film-strip":true,"film-strip-dir":"phantomas/images/1433360349885","url":"https://responsiveimages.org","user-agent":"phantomas/1.10.0 (PhantomJS/1.9.8; darwin x64)"} +0ms
  phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=true"] +0ms
  phantomas Spawned with pid #5373 +5ms
  phantomas:ipc filmStrip: ["phantomas/images/1433360349885/screenshot-2015-06-03T19-39-11-28.png",28] +2s
  phantomas:ipc progress: [10,10] +18ms
  phantomas:progress 10% (+10%) +1ms
  phantomas:ipc metric: ["timeToFirstByte",0] +104ms
  phantomas:ipc metric: ["timeToLastByte",170] +0ms
  phantomas:ipc metric: ["statusCodesTrail",""] +0ms
  phantomas:ipc milestone: ["responseEnd"] +0ms
  phantomas:ipc filmStrip: ["phantomas/images/1433360349885/screenshot-2015-06-03T19-39-11-152.png",152] +129ms
  phantomas:ipc exit: [254,"Page loading failed"] +2ms
  phantomas:results Process returned code #254 +22ms
  phantomas:results Error when parsing JSON (SyntaxError: Unexpected end of input) +0ms
  phantomas:results Rejecting a promise with 254 exit code +0ms
  phantomas nodejs v0.12.0 +1ms
  phantomas phantomas v1.10.0 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas +0ms
  phantomas URL: <https://responsiveimages.org> +0ms
  phantomas Options: {"ignore-ssl-errors":true,"ssl-protocol":"any","debug":true} +0ms
  phantomas Temporary directory: /var/folders/03/cgg2bwfd6j92tfllylt5b91m0000gn/T//phantomas/cd649284-2109-4ce8-a687-f29ffced84f9/ +0ms
  phantomas:engines Engine "webkit": PhantomJS v1.9.8 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/phantomjs/lib/phantom/bin/phantomjs +1ms
  phantomas:engines Engine "gecko": SlimerJS v0.9.5 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/slimerjs/lib/slimer/slimerjs +0ms
  phantomas:engines Running /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/scripts/phantomas.js (using PhantomJS) +0ms
  phantomas:engines Passing phantomas options: {"url":"https://responsiveimages.org","user-agent":"phantomas/1.10.0 (PhantomJS/1.9.8; darwin x64)"} +0ms
  phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=true"] +0ms
  phantomas Spawned with pid #5380 +2ms
  phantomas:ipc progress: [10,10] +1s
  phantomas:progress 10% (+10%) +0ms
  phantomas:ipc metric: ["timeToFirstByte",0] +59ms
  phantomas:ipc metric: ["timeToLastByte",112] +0ms
  phantomas:ipc metric: ["statusCodesTrail",""] +0ms
  phantomas:ipc milestone: ["responseEnd"] +0ms
  phantomas:ipc exit: [254,"Page loading failed"] +2ms
  phantomas:results Process returned code #254 +20ms
  phantomas:results Error when parsing JSON (SyntaxError: Unexpected end of input) +0ms
  phantomas:results Rejecting a promise with 254 exit code +1ms
  phantomas nodejs v0.12.0 +0ms
  phantomas phantomas v1.10.0 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas +0ms
  phantomas URL: <https://responsiveimages.org> +0ms
  phantomas Options: {"ignore-ssl-errors":true,"ssl-protocol":"any","debug":true} +0ms
  phantomas Temporary directory: /var/folders/03/cgg2bwfd6j92tfllylt5b91m0000gn/T//phantomas/bca89c53-5b7b-4e37-8227-3e72e899048b/ +0ms
  phantomas:engines Engine "webkit": PhantomJS v1.9.8 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/phantomjs/lib/phantom/bin/phantomjs +0ms
  phantomas:engines Engine "gecko": SlimerJS v0.9.5 installed in /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/node_modules/slimerjs/lib/slimer/slimerjs +0ms
  phantomas:engines Running /Users/stefan/Sites/grunt-phantomas/node_modules/phantomas/scripts/phantomas.js (using PhantomJS) +0ms
  phantomas:engines Passing phantomas options: {"url":"https://responsiveimages.org","user-agent":"phantomas/1.10.0 (PhantomJS/1.9.8; darwin x64)"} +0ms
  phantomas:engines Passing engine options: ["--ignore-ssl-errors=true","--ssl-protocol=any","--debug=true"] +0ms
  phantomas Spawned with pid #5381 +2ms
  phantomas:ipc progress: [10,10] +2s
  phantomas:progress 10% (+10%) +0ms
  phantomas:ipc metric: ["timeToFirstByte",0] +53ms
  phantomas:ipc metric: ["timeToLastByte",102] +0ms
  phantomas:ipc metric: ["statusCodesTrail",""] +0ms
  phantomas:ipc milestone: ["responseEnd"] +0ms
  phantomas:ipc exit: [254,"Page loading failed"] +2ms
  phantomas:results Process returned code #254 +23ms
  phantomas:results Error when parsing JSON (SyntaxError: Unexpected end of input) +0ms
  phantomas:results Rejecting a promise with 254 exit code +0ms
>> 3 Phantomas execution(s) done -> checking results:
>> Phantomas execution not successful -> 254
>> Phantomas execution not successful -> 254
>> Phantomas execution not successful -> 254

WRITING RESULT FILES.
>> SOMETHING WENT WRONG...
>> No run was successful.
macbre commented 9 years ago
$ phantomas "https://responsiveimages.org/" --verbose
...
20:02:30.320 Blocked request by phantomjs: <https://responsiveimages.org/>
20:02:30.321 Event abort emitted
20:02:30.321 recv: "start" stage not registered for <https://responsiveimages.org/>!
20:02:30.321 contentLength missing: {"url":"https://responsiveimages.org/"}
20:02:30.322 recv: HTTP 200 <https://responsiveimages.org/> [undefined]
...
phantomas: (254) Page loading failed

Something strange is happening. Please file a ticket in phantomas project. Fails with --gecko as well.

stefanjudis commented 9 years ago

Closing here, because problem is not on this side. :)