From ac78e2963b8dfed7d3b1ddf92de4db255ec299fc Mon Sep 17 00:00:00 2001 From: Tom Marien Date: Sat, 5 Nov 2022 23:46:18 +0100 Subject: [PATCH] fix(connection): ensure pooled connections get released The PoolConnection is listening for the end event to be emitted to close the connection, but the connection is not listening to the underlying end event emitted by the net.Socket. --- lib/connection.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/connection.js b/lib/connection.js index e2720be078..0733b11c62 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -96,6 +96,10 @@ class Connection extends EventEmitter { } this.packetParser.execute(data); }); + this.stream.on('end', () => { + // emit the end event so that the pooled connection can close the connection + this.emit('end'); + }); this.stream.on('close', () => { // we need to set this flag everywhere where we want connection to close if (this._closing) {