Skip to content

Commit

Permalink
fix(connection): ensure pooled connections get released
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tommarien committed Nov 5, 2022
1 parent 1eef0a7 commit 8276221
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8276221

Please sign in to comment.