Permalink
Browse files

fix: Prevent error event after connect timeout

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...
1 parent d8ed1ac commit f5a0f95a5a522ad6a312170201b829e70c866976 @Hadis-Fard Hadis-Fard committed with arthurschreiber Jan 20, 2018
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/connection.js
View
@@ -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);

0 comments on commit f5a0f95

Please sign in to comment.