diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-02-25 21:43:23 +0100 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2018-03-04 12:43:13 +0100 |
commit | eda702104b3447dd56dc635565b4c88b0e04685a (patch) | |
tree | f5cddcddb7102965c8f4d2ac10e4da4e89d07390 | |
parent | 1ebd966d2cef9d026b947c3c36d49c9989a60701 (diff) | |
download | android-node-v8-eda702104b3447dd56dc635565b4c88b0e04685a.tar.gz android-node-v8-eda702104b3447dd56dc635565b4c88b0e04685a.tar.bz2 android-node-v8-eda702104b3447dd56dc635565b4c88b0e04685a.zip |
tls: better error message for socket disconnect
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: https://github.com/nodejs/node/pull/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>
-rw-r--r-- | lib/_tls_wrap.js | 4 | ||||
-rw-r--r-- | test/parallel/test-tls-empty-sni-context.js | 2 | ||||
-rw-r--r-- | test/parallel/test-tls-sni-option.js | 4 |
3 files changed, 6 insertions, 4 deletions
diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index b3c48b950c..c472564270 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -1074,7 +1074,6 @@ function onConnectSecure() { this.emit('secureConnect'); } - // Uncork incoming data this.removeListener('end', onConnectEnd); } @@ -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'); error.code = 'ECONNRESET'; error.path = options.path; error.host = options.host; diff --git a/test/parallel/test-tls-empty-sni-context.js b/test/parallel/test-tls-empty-sni-context.js index 9a8e3449f0..48f9a52463 100644 --- a/test/parallel/test-tls-empty-sni-context.js +++ b/test/parallel/test-tls-empty-sni-context.js @@ -29,6 +29,6 @@ const server = tls.createServer(options, (c) => { }, common.mustNotCall()); c.on('error', common.mustCall((err) => { - assert(/socket hang up/.test(err.message)); + assert(/Client network socket disconnected/.test(err.message)); })); })); diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js index d4b6a8e190..b3a5adb47c 100644 --- a/test/parallel/test-tls-sni-option.js +++ b/test/parallel/test-tls-sni-option.js @@ -175,7 +175,9 @@ process.on('exit', function() { ]); assert.deepStrictEqual(clientResults, [true, true, true, false, false]); assert.deepStrictEqual(clientErrors, [ - null, null, null, null, 'socket hang up' + null, null, null, null, + 'Client network socket disconnected before secure TLS ' + + 'connection was established' ]); assert.deepStrictEqual(serverErrors, [ null, null, null, null, 'Invalid SNI context' |