grunt-critical icon indicating copy to clipboard operation
grunt-critical copied to clipboard

Unhandled rejection Error. Several errors: "socket hang up", "Wrong status code 502" and so on

Open shervud opened this issue 8 years ago • 1 comments

Hello, everyone. For example I have url "https://www.cleanandclear.com.vn". Node version is 9.0.0 npm version 3.8.6 grunt 0.4.5

My config is: grunt.config('critical', { debug: { options: { base: './', timeout: 60000, penthouse: { "strict": false, "renderWaitTime": 5000, "blockJSRequests": false, "pageLoadSkipTimeout": 20000 }, width: 1920, height: 1920, pathPrefix: "" }, src: "https://www.cleanandclear.com.vn/", dest: "my-critical.css" } });

I used grunt-critical 0.3.0 and always got the following error:

Running "critical:debug" (critical) task File "my-critical.css" failed. Error opening url 'https://www.cleanandclear.com.vn/': Connection closed

But I found the same problem here https://github.com/addyosmani/critical/issues/240 and then I updated grunt-critical from 0.3.0 to 1.1.0 , which uses penthouse with Chrome headless, instead of PhantomJS.

But never mind is it grunt-critical 0.3.0 or 1.1.0, very rarely and randomly I am getting the following error:

1st error:

Unhandled rejection Error: socket hang up at createHangUpError (_http_client.js:330:15) at TLSSocket.socketOnEnd (_http_client.js:423:23) at emitNone (events.js:120:20) at TLSSocket.emit (events.js:218:7) at endReadableNT (_stream_readable.js:1054:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)

The worst thing is this error appears randomly, say on 9 of 10 times it's ok, and 1 of 10 it could fail. All run options and parameters are similar, so I even don't have any idea...

2nd error:

Running "critical:debug" (critical) task Unhandled rejection Error: Wrong status code 502 for https://example.com/some-css.css at Request.request [as _callback] (/node_modules/critical/lib/file-helper.js:146:31) at Request.self.callback (/node_modules/request/request.js:188:22) at emitTwo (events.js:135:13) at Request.emit (events.js:224:7) at Request. (/node_modules/request/request.js:1171:10) at emitOne (events.js:125:13) at Request.emit (events.js:221:7) at IncomingMessage. (/node_modules/request/request.js:1091:12) at Object.onceWrapper (events.js:322:30) at emitNone (events.js:120:20) at IncomingMessage.emit (events.js:218:7) at endReadableNT (_stream_readable.js:1054:12) at _combinedTickCallback (internal/process/next_tick.js:138:11) at process._tickCallback (internal/process/next_tick.js:180:9)

So, question: is there any way to handle these Unhandled errors? Thank you.

shervud avatar Dec 11 '17 10:12 shervud

@shervud: sorry for the late response. This error seems like a problem with the server and not with critical itself. Can you verify that this error doesn't occur without critical?

bezoerb avatar Aug 12 '18 20:08 bezoerb