Skip to content

Commit

Permalink
fix: Prevent error event after connect timeout
Browse files Browse the repository at this point in the history
When the initial connection to the database timed out, an `error` event was erronously emitted on the connection, and a socket instance was leaked and never released.
  • Loading branch information
Hadis Fard authored and arthurschreiber committed Jan 20, 2018
1 parent d8ed1ac commit f5a0f95
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,11 @@ class Connection extends EventEmitter {
return this.socketError(err);
}

if (this.state === this.STATE.FINAL) {
socket.destroy();
return;
}

this.socket = socket;
this.socket.on('error', this.socketError);
this.socket.on('close', this.socketClose);
Expand Down

0 comments on commit f5a0f95

Please sign in to comment.