diff --git a/lib/net.js b/lib/net.js index 643137b70d0641..35bfd33eaaf473 100644 --- a/lib/net.js +++ b/lib/net.js @@ -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();