net: partially revert "simplify Socket.prototype._final"

Partially revert b7e6ccd0cc
because it broke a test that was added since its last CI run.

Refs: https://github.com/nodejs/node/pull/24075
Refs: https://github.com/nodejs/node/pull/23866

PR-URL: https://github.com/nodejs/node/pull/24288
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
This commit is contained in:
Anna Henningsen authored and Myles Borins committed 2018-12-26 11:18:54 -05:00
1 parent 704b68aee4
commit 897114bf94
1 file changed
+6
+6
View File
@@ -344,6 +344,12 @@ Socket.prototype._final = function(cb) {
return this.once('connect', () => this._final(cb));
}
// TODO(addaleax): This should not be necessary.
if (!this.readable || this._readableState.ended) {
cb();
return this.destroy();
}
if (!this._handle)
return cb();