Skip to content

Commit

Permalink
net: treat ENOTCONN at shutdown as success
Browse files Browse the repository at this point in the history
While it is not entirely clear why this condition is being
triggered, it does resolve a reported bug.

Fixes: #26315

Backport-PR-URL: #29968
PR-URL: #29912
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
addaleax authored and BethGriggs committed Oct 16, 2019
1 parent 13d8549 commit 69bf5b7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ const {
const assert = require('assert');
const {
UV_EADDRINUSE,
UV_EINVAL
UV_EINVAL,
UV_ENOTCONN
} = process.binding('uv');

const { Buffer } = require('buffer');
Expand Down Expand Up @@ -357,7 +358,7 @@ Socket.prototype._final = function(cb) {
req.callback = cb;
var 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'));
Expand Down

0 comments on commit 69bf5b7

Please sign in to comment.