net: use callback to properly propagate error

The socket will be destroyed upstream through the proper error
flow.

PR-URL: https://github.com/nodejs/node/pull/29178
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Robert Nagy 2019-08-17 13:08:09 +02:00 committed by Rich Trott
parent 490ec9b9c9
commit cc7cec25c5

View File

@ -685,7 +685,7 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
this._pendingEncoding = '';
if (!this._handle) {
this.destroy(new ERR_SOCKET_CLOSED(), cb);
cb(new ERR_SOCKET_CLOSED());
return false;
}