Skip to content

Commit b8b1f5f

Browse files
committed
Fix issue with phantomjs connecting via TLS
1 parent 878c399 commit b8b1f5f

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ test-interaction.js
33
test-read.js
44
npm-debug.log
55
newrelic_agent.log
6+
curl_command
67
.DS_Store

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "critical-css-server",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "Build critical path css asynchronously on demand",
55
"engines": {
66
"node": "7.4.0"

src/generator.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,21 @@ var tmpDir = require('os').tmpdir();
77
var extend = require('extend');
88

99
var tmpPath = path.join(tmpDir, 'crit.css');
10-
var forced = ['.is-logged-in', '.is-logged-out', '.right-off-canvas-menu'];
10+
var forced = [];
11+
12+
var defaultOptions = { forceInclude: forced, ignoreConsole: true };
13+
var phantomJsOptions = { 'ssl-protocol': 'any' };
1114

1215
module.exports = function () {
1316
var me;
1417

1518
me = {
1619
generate: bluebird.promisify(function (sourceUrl, cssUrl, options, callback) {
1720
try {
18-
options = extend({ forceInclude: forced, ignoreConsole: true }, options);
21+
options = extend({}, defaultOptions, options);
1922

2023
request({ uri: cssUrl, timeout: 10000 }).on('error', callback).pipe(fs.createWriteStream(tmpPath)).on('close', function() {
21-
penthouse({ url: sourceUrl, css: tmpPath })
24+
penthouse(extend(options, { url: sourceUrl, css: tmpPath, phantomJsOptions: phantomJsOptions }))
2225
.then(function (criticalCss) { callback(null, criticalCss); })
2326
.catch(callback);
2427
});

src/workers.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ module.exports = function (queue) {
1515
});
1616

1717
queue.on('error', function (job) {
18-
console.log('job failed! ', job.data);
18+
console.log('job error! ', job.data);
19+
throw arguments;
1920
});
2021

2122
queue.on('failed', function (job) {
2223
console.log('job failed! ', job.data);
24+
throw console.log(arguments[0], arguments[1], arguments[2]);
2325
});
2426

2527
queue.process(function (job, done) {

0 commit comments

Comments
 (0)