Skip to content

Commit 343caef

Browse files
committed
Fix race in error handling test
1 parent 7c21815 commit 343caef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/integration/connection-pool/error-tests.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,27 @@ pg.connect(helper.config, assert.success(function(client, done) {
1313
client2.id = 2;
1414
var pidColName = 'procpid'
1515
helper.versionGTE(client2, '9.2.0', assert.success(function(isGreater) {
16+
console.log(isGreater)
1617
var killIdleQuery = 'SELECT pid, (SELECT pg_terminate_backend(pid)) AS killed FROM pg_stat_activity WHERE state = $1';
1718
var params = ['idle'];
1819
if(!isGreater) {
1920
killIdleQuery = 'SELECT procpid, (SELECT pg_terminate_backend(procpid)) AS killed FROM pg_stat_activity WHERE current_query LIKE $1';
2021
params = ['%IDLE%']
2122
}
22-
done2();
23+
2324
//subscribe to the pg error event
2425
assert.emits(pg, 'error', function(error, brokenClient) {
2526
assert.ok(error);
2627
assert.ok(brokenClient);
2728
assert.equal(client.id, brokenClient.id);
2829
});
30+
2931
//kill the connection from client
3032
client2.query(killIdleQuery, params, assert.success(function(res) {
3133
//check to make sure client connection actually was killed
3234
assert.lengthIs(res.rows, 1);
35+
//return client2 to the pool
36+
done2();
3337
pg.end();
3438
}));
3539
}));

0 commit comments

Comments
 (0)