From 1566f683fd0f2011a8649225fe50fb0841cbd6e7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 10 Oct 2019 02:22:38 +0200 Subject: [PATCH] net: treat ENOTCONN at shutdown as success While it is not entirely clear why this condition is being triggered, it does resolve a reported bug. Fixes: https://github.com/nodejs/node/issues/26315 PR-URL: https://github.com/nodejs/node/pull/29912 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- lib/net.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/net.js b/lib/net.js index 094685af00957a..b682ae7fb7c2ea 100644 --- a/lib/net.js +++ b/lib/net.js @@ -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'); @@ -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'));