Comparing version 3.5.1 to 3.5.2
35
index.js
@@ -255,3 +255,3 @@ 'use strict' | ||
if (this.options.maxLifetimeSeconds !== 0) { | ||
setTimeout(() => { | ||
const maxLifetimeTimeout = setTimeout(() => { | ||
this.log('ending client due to expired lifetime') | ||
@@ -269,2 +269,5 @@ this._expired.add(client) | ||
}, this.options.maxLifetimeSeconds * 1000) | ||
maxLifetimeTimeout.unref() | ||
client.once('end', () => clearTimeout(maxLifetimeTimeout)) | ||
} | ||
@@ -408,16 +411,20 @@ | ||
this.log('dispatching query') | ||
client.query(text, values, (err, res) => { | ||
this.log('query dispatched') | ||
client.removeListener('error', onError) | ||
if (clientReleased) { | ||
return | ||
} | ||
clientReleased = true | ||
try { | ||
client.query(text, values, (err, res) => { | ||
this.log('query dispatched') | ||
client.removeListener('error', onError) | ||
if (clientReleased) { | ||
return | ||
} | ||
clientReleased = true | ||
client.release(err) | ||
if (err) { | ||
return cb(err) | ||
} | ||
return cb(undefined, res) | ||
}) | ||
} catch (err) { | ||
client.release(err) | ||
if (err) { | ||
return cb(err) | ||
} else { | ||
return cb(undefined, res) | ||
} | ||
}) | ||
return cb(err) | ||
} | ||
}) | ||
@@ -424,0 +431,0 @@ return response.result |
{ | ||
"name": "pg-pool", | ||
"version": "3.5.1", | ||
"version": "3.5.2", | ||
"description": "Connection pool for node-postgres", | ||
@@ -40,3 +40,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "4fa7ee891a456168a75695ac026792136f16577f" | ||
"gitHead": "c99fb2c127ddf8d712500db2c7b9a5491a178655" | ||
} |
@@ -40,2 +40,14 @@ 'use strict' | ||
it('Catches errors in client.query', async function () { | ||
let caught = false | ||
const pool = new Pool() | ||
try { | ||
await pool.query(null) | ||
} catch (e) { | ||
caught = true | ||
} | ||
pool.end() | ||
expect(caught).to.be(true) | ||
}) | ||
describe('calling release more than once', () => { | ||
@@ -42,0 +54,0 @@ it( |
@@ -6,3 +6,3 @@ // This test is meant to be spawned from idle-timeout.js | ||
const pool = new Pool({ idleTimeoutMillis: 200, ...(allowExitOnIdle ? { allowExitOnIdle: true } : {}) }) | ||
const pool = new Pool({ maxLifetimeSeconds: 2, idleTimeoutMillis: 200, ...(allowExitOnIdle ? { allowExitOnIdle: true } : {}) }) | ||
pool.query('SELECT NOW()', (err, res) => console.log('completed first')) | ||
@@ -9,0 +9,0 @@ pool.on('remove', () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68309
1620