diff --git a/lib/net.js b/lib/net.js index baaf2180d1b463..c0d2576afc496b 100644 --- a/lib/net.js +++ b/lib/net.js @@ -39,7 +39,8 @@ const { const assert = require('internal/assert'); const { UV_EADDRINUSE, - UV_EINVAL + UV_EINVAL, + UV_ENOTCONN } = internalBinding('uv'); const { Buffer } = require('buffer'); @@ -403,7 +404,7 @@ Socket.prototype._final = function(cb) { req.callback = cb; const err = this._handle.shutdown(req); - if (err === 1) // synchronous finish + if (err === 1 || err === UV_ENOTCONN) // synchronous finish return afterShutdown.call(req, 0); else if (err !== 0) return this.destroy(errnoException(err, 'shutdown'));