Repository: brianc/node-postgres (language: javascript)

Issue:
pg-pool Exception
TypeError: client.ref is not a function
at BoundPool._pulseQueue (../node_modules/pg-pool/index.js:140:14)

I'm using pg@8.6.0 which, as of today, now installs pg-pool@3.4.0




Discussion / hints:
That's unfortunate - AFAIK there's no way to retroactively update the old package to have it use the older version of pg-pool.  I suggest you either upgrade `pg` to `8.7.0` or add `pg-pool@3.3.0` to your package.json.  I can patch `pg-pool` to not blow up if that method is missing as well.

Fix patch:
diff --git a/packages/pg-pool/index.js b/packages/pg-pool/index.js
index 5557de5c0..48bf5c788 100644
--- a/packages/pg-pool/index.js
+++ b/packages/pg-pool/index.js
@@ -137,7 +137,7 @@ class Pool extends EventEmitter {
       const idleItem = this._idle.pop()
       clearTimeout(idleItem.timeoutId)
       const client = idleItem.client
-      client.ref()
+      client.ref && client.ref()
       const idleListener = idleItem.idleListener
 
       return this._acquireClient(client, pendingItem, idleListener, false)


Test patch:
diff --git a/packages/pg/test/integration/client/connection-timeout-tests.js b/packages/pg/test/integration/client/connection-timeout-tests.js
index 6b99698bc..7a3ee4447 100644
--- a/packages/pg/test/integration/client/connection-timeout-tests.js
+++ b/packages/pg/test/integration/client/connection-timeout-tests.js
@@ -7,7 +7,7 @@ const suite = new helper.Suite()
 
 const options = {
   host: 'localhost',
-  port: 54321,
+  port: Math.floor(Math.random() * 2000) + 2000,
   connectionTimeoutMillis: 2000,
   user: 'not',
   database: 'existing',