Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
shervud opened this issue Dec 11, 2017 · 1 comment

Comments

@shervud
Copy link

shervud commented Dec 11, 2017

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 addyosmani/critical#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.

@bezoerb
Copy link
Owner

bezoerb commented Aug 12, 2018

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants