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

pg-connection-string: Shouldn't idleTimeoutMillis be considered? For pool usage patterns? #3279

Open
deostroll opened this issue Jul 24, 2024 · 1 comment

Comments

@deostroll
Copy link

https://github.com/brianc/node-postgres/blob/master/packages/pg-connection-string/index.js

👆 The code here is not setting anything with respect to idleTimeoutMillis. Other parameters such as user, password, ssl, etc are set.

Therefore when using connection string usage - what is the actual design? Should the developer pass the connectionString and idleTmeoutMillis together for pool configurations? Or should the developer set in the connectionString itself.

I don't see anything relating to idleTimeoutMillis here either: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS

Please advice.

@hjr3
Copy link
Contributor

hjr3 commented Nov 16, 2024

The spec is here: https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS

We can set idleTimeoutMillis in the query params, but that will give us a string instead of a number.

Looking at

this.idle_in_transaction_session_timeout = val('idle_in_transaction_session_timeout', config, false)
this.query_timeout = val('query_timeout', config, false)
if (config.connectionTimeoutMillis === undefined) {
this.connect_timeout = process.env.PGCONNECT_TIMEOUT || 0
} else {
this.connect_timeout = Math.floor(config.connectionTimeoutMillis / 1000)
}
if (config.keepAlive === false) {
this.keepalives = 0
} else if (config.keepAlive === true) {
this.keepalives = 1
}
it should still work though.

I do not see idleTimeoutMills in the code base or https://node-postgres.com/apis/client docs. Maybe you meant connectionTimeoutMillis?

const config = parse('postgres://user:pw@host/db?connectionTimeoutMillis=100');
assert(config.connectionTimeoutMillis === '100'); // true

and will be honored here:

if (config.connectionTimeoutMillis === undefined) {
this.connect_timeout = process.env.PGCONNECT_TIMEOUT || 0
} else {
this.connect_timeout = Math.floor(config.connectionTimeoutMillis / 1000)
}

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

No branches or pull requests

2 participants