diff --git a/src/v1/internal/ch-node.js b/src/v1/internal/ch-node.js index c48b2184a..d13239f4d 100644 --- a/src/v1/internal/ch-node.js +++ b/src/v1/internal/ch-node.js @@ -266,6 +266,7 @@ class NodeChannel { this._open = true; this._error = null; this._handleConnectionError = this._handleConnectionError.bind(this); + this._handleConnectionTerminated = this._handleConnectionTerminated.bind(this); this._encrypted = opts.encrypted; this._conn = connect(opts, () => { @@ -299,10 +300,8 @@ class NodeChannel { } _handleConnectionTerminated() { - this._error = new Error('Connection was closed by server'); - if( this.onerror ) { - this.onerror(this._error); - } + this._open = false; + this._conn = undefined; } isEncrypted() { diff --git a/src/v1/internal/pool.js b/src/v1/internal/pool.js index ed53bdf05..37d898900 100644 --- a/src/v1/internal/pool.js +++ b/src/v1/internal/pool.js @@ -46,6 +46,8 @@ class Pool { if( this._validate(resource) ) { return resource; + } else { + this._destroy(resource); } }