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

Partially revert b7e6ccd0cc60f20cc397e6ac0705bb3f38c7d225
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 2018-11-10 20:59:50 +01:00
parent f77bb3cb00
commit fb6c6692a8
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -345,6 +345,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();