node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

[Question]. Pass client config when using pool

Open JSEvgeny opened this issue 2 years ago • 0 comments

Hey there and thank you for you time!

I have a question about using connection pool. The idea is to pass some configuration to all clients inside that pool, specifically idle_in_transaction_session_timeout. But because I'm using Pool, I configure the pool with corresponding settings and not the clients inside the pool.

As a workaround I use a connect event, but is there a better way to achieve this?

pool.on('connect', async (client) => {
      await client
        .query(`SET idle_in_transaction_session_timeout=30000`)

JSEvgeny avatar Oct 31 '23 13:10 JSEvgeny