Skip to content

Commit ec3924c

Browse files
committed
[CONJS-196] 3.0 regression on release connection #195
In 3.0, when releasing connection to pool not with connection.release() but connection.close(), connection wasn't given back to pool, but killed. When killing connection, server send a ER_CONNECTION_KILLED error that can sometime be caught by connector before socket is closed, but that's not assured, then having just an ER_SOCKET_UNEXPECTED_CLOSE error.
1 parent 709da77 commit ec3924c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/pool-callback.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ class PoolCallback extends EventEmitter {
9696
.getConnection(cmdParam)
9797
.then((baseConn) => {
9898
const cc = new ConnectionCallback(baseConn);
99-
cc.end = (cb) => {
100-
cc.release(cb);
101-
};
99+
cc.end = (cb) => cc.release(cb);
100+
cc.close = (cb) => cc.release(cb);
102101
cb(null, cc);
103102
})
104103
.catch(cb);

lib/pool-promise.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class PoolPromise extends EventEmitter {
8686
return new Promise(baseConn.release);
8787
};
8888
conn.end = conn.release;
89+
conn.close = conn.release;
8990
return conn;
9091
});
9192
}

0 commit comments

Comments
 (0)