Skip to content

Commit ce8ee5c

Browse files
authored
Merge pull request #149 from Gertt/fix/terminated-connections
improve closed connection handling
2 parents 4120c73 + b1ad35c commit ce8ee5c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/v1/internal/ch-node.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class NodeChannel {
266266
this._open = true;
267267
this._error = null;
268268
this._handleConnectionError = this._handleConnectionError.bind(this);
269+
this._handleConnectionTerminated = this._handleConnectionTerminated.bind(this);
269270

270271
this._encrypted = opts.encrypted;
271272
this._conn = connect(opts, () => {
@@ -299,10 +300,8 @@ class NodeChannel {
299300
}
300301

301302
_handleConnectionTerminated() {
302-
this._error = new Error('Connection was closed by server');
303-
if( this.onerror ) {
304-
this.onerror(this._error);
305-
}
303+
this._open = false;
304+
this._conn = undefined;
306305
}
307306

308307
isEncrypted() {

src/v1/internal/pool.js

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class Pool {
4646

4747
if( this._validate(resource) ) {
4848
return resource;
49+
} else {
50+
this._destroy(resource);
4951
}
5052
}
5153

0 commit comments

Comments
 (0)