From 24dcb3ccb9f0b0acfd94658ab43eb15014689e72 Mon Sep 17 00:00:00 2001 From: Mike Ryan Date: Fri, 28 Jan 2022 11:35:27 -0600 Subject: [PATCH] client: make destroy() always destroy the socket If client.destroy() is called, always destroy the underlying socket so that file descriptor is freed. This matches behavior of node's Socket and Writable. Previous behavior made this conditional on writability of the socket. If the socket wasn't writable, then client.destroy() wouldn't actually destroy the socket, the file descriptor would remain open, and the node process would hang on exit.. It might timeout after 15 minutes, if you're lucky. fixes #1124 --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 80f372a8..49f98c72 100644 --- a/lib/client.js +++ b/lib/client.js @@ -1086,7 +1086,7 @@ class Client extends EventEmitter { } destroy() { - this._sock && isWritable(this._sock) && this._sock.destroy(); + this._sock && this._sock.destroy(); return this; }