Skip to content

Commit 4dc4821

Browse files
committed
Fixed error thrown if pool._logStats called after terminate
1 parent 719e12a commit 4dc4821

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

lib/pool.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@ function terminate(terminateCb) {
220220
function logStats() {
221221
var self = this;
222222
var averageTimeInQueue;
223+
224+
if (!self._isValid) {
225+
console.log('_logStats must be called prior to terminating pool.');
226+
return;
227+
}
223228

224229
if (self._enableStats !== true) {
225230
console.log('Pool statistics not enabled');

test/pool.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,4 +905,50 @@ describe('2. pool.js', function(){
905905
);
906906
});
907907
});
908+
909+
describe('2.9 connection request queue (_enableStats & _logStats functionality)', function(){
910+
it('2.9.1 works after the pool as been terminated', function(done) {
911+
oracledb.createPool(
912+
{
913+
externalAuth : credential.externalAuth,
914+
user : credential.user,
915+
password : credential.password,
916+
connectString : credential.connectString,
917+
poolMin : 0,
918+
poolMax : 1,
919+
poolIncrement : 1,
920+
poolTimeout : 1,
921+
queueRequests : true, //default
922+
_enableStats : true
923+
},
924+
function(err, pool){
925+
should.not.exist(err);
926+
927+
pool.getConnection(function(err, conn) {
928+
should.not.exist(err);
929+
930+
conn.execute('select 1 from dual', function(err, result) {
931+
should.not.exist(err);
932+
933+
conn.release(function(err) {
934+
should.not.exist(err);
935+
936+
pool.terminate(function(err) {
937+
should.not.exist(err);
938+
939+
try {
940+
pool._logStats();
941+
} catch (err) {
942+
should.not.exist(err);
943+
}
944+
945+
done();
946+
});
947+
});
948+
});
949+
});
950+
}
951+
);
952+
});
953+
});
908954
})

0 commit comments

Comments
 (0)