Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation - How to pass in idle_in_transaction_session_timeout #2381

Closed
legopin opened this issue Oct 16, 2020 · 1 comment · Fixed by brianc/node-postgres-docs#106
Closed

Comments

@legopin
Copy link

legopin commented Oct 16, 2020

Hello,

I'm having trouble passing this config into the client: idle_in_transaction_session_timeout implemented here: #2049

However I couldn't figure out where to pass it in given the starting example of

const { Pool } = require('pg');
const pool = new Pool();

pool.query('SQL...')

I looked into the config document and did not see idle_in_transaction_session_timeout as a documented property of the PoolConfig type

It would be nice to have the available options documented here: https://node-postgres.com/api/pool#constructor

Thanks

@mriedem
Copy link
Contributor

mriedem commented Oct 16, 2020

It should just be pass through to the Client object I think. The options passed to the Pool object get saved here:

https://github.com/brianc/node-postgres/blob/pg%408.4.1/packages/pg-pool/index.js#L64

which get passed to the Client object that gets constructed by the Pool here:

https://github.com/brianc/node-postgres/blob/pg%408.4.1/packages/pg-pool/index.js#L201

those go into this ConnectionParameters object:

https://github.com/brianc/node-postgres/blob/pg%408.4.1/packages/pg/lib/client.js#L19

and the idle_in_transaction_session_timeout param should be used here:

https://github.com/brianc/node-postgres/blob/pg%408.4.1/packages/pg/lib/client.js#L398

The ConnectionParameters object contains that field here:

https://github.com/brianc/node-postgres/blob/pg%408.4.1/packages/pg/lib/connection-parameters.js#L96

So I think idle_in_transaction_session_timeout just needs to be documented like statement_timeout here:

https://node-postgres.com/api/client#constructor

Because those just get passed through to postgres: https://www.postgresql.org/docs/current/runtime-config-client.html

Also note that the Pool constructor docs https://node-postgres.com/api/pool#constructor mention:

The config passed to the pool is also passed to every client instance within the pool when the pool creates that client.

So something like: const pool = new Pool({ idle_in_transaction_session_timeout: 60000 }) will get passed through down to the Client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants