-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
tls: better error message for socket disconnect #18989
Conversation
The error emitted when a connection is closed before the TLS handshake completes seemed rather unspefic by just saying `socket hang up`. Use a more verbose message, that also indicates that this is a purely client-side error, and remove a misleading comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are actually 4 errors with the same message (socket hang up
) in lib/
...would be even better if the error creation is put into a helper in lib/internal/errors.js
and reuse it in other places.
Yes that error message is also used in the plain HTTP client if the socket if destroyed before response headers are read. The meaning is different from the one used here though. |
@@ -1083,7 +1082,8 @@ function onConnectEnd() { | |||
if (!this._hadError) { | |||
const options = this[kConnectOptions]; | |||
this._hadError = true; | |||
const error = new Error('socket hang up'); | |||
const error = new Error('Client network socket disconnected before ' + | |||
'secure TLS connection was established'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember if we're keeping this intentionally with the old errors or if this needs to be converted to use internal/errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to switch to the internal/errors and override the code for now. It is not a strong opinion though and I am fine with keeping it as it is for now as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I’m going to leave this out of this PR.
I don’t think I’m a fan of changing the code
property of exactly those errors where we always provided one, though.
semver-major because of the error message change. |
@jasnell @joyeecheung I’m not sure, do we have a story for these kinds of errors, that have a |
I don't have a great answer for that either. |
@addaleax I've done a few of those in c0762c2 . Although I've only moved the creation code into helpers inside It does not have to be semver-major if the message is not changed, but that's what this PR is about, so I think it'll still be semver-major. |
Also, these errors all have |
@joyeecheung I actually guess that quite some code in the wild relies on the old |
@@ -1083,7 +1082,8 @@ function onConnectEnd() { | |||
if (!this._hadError) { | |||
const options = this[kConnectOptions]; | |||
this._hadError = true; | |||
const error = new Error('socket hang up'); | |||
const error = new Error('Client network socket disconnected before ' + | |||
'secure TLS connection was established'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to switch to the internal/errors and override the code for now. It is not a strong opinion though and I am fine with keeping it as it is for now as well.
Landed in eda7021 |
The error emitted when a connection is closed before the TLS handshake completes seemed rather unspefic by just saying `socket hang up`. Use a more verbose message, that also indicates that this is a purely client-side error, and remove a misleading comment. PR-URL: #18989 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The error emitted when a connection is closed before the TLS handshake completes seemed rather unspefic by just saying `socket hang up`. Use a more verbose message, that also indicates that this is a purely client-side error, and remove a misleading comment. PR-URL: nodejs#18989 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
The error emitted when a connection is closed before the
TLS handshake completes seemed rather unspefic by just saying
socket hang up
.Use a more verbose message, that also indicates that this is
a purely client-side error, and remove a misleading comment.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
tls