Skip to content

Pool#connect resolves error as success. #1142

Description

@calebmer

I initialized a pool using pg.Pool and then in an async function ran:

const client = await pgPool.connect()
client.query('begin')
...
client.query('commit')
client.release()

But I keep getting the error:

TypeError: client.query is not a function

Upon further investigation if I write:

const client = await pgPool.connect()
console.log(client)

I get the following:

{ Error: connect ECONNREFUSED 127.0.0.1:5432
    at Object.exports._errnoException (util.js:1036:11)
    at exports._exceptionWithHostPort (util.js:1059:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432,
  release: [Function: bound ] }

Note the release property which gets added by the pool when it thinks it has a client.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions