Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

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

Closed
deostroll opened this issue Jul 24, 2024 · 2 comments
Assignees

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
Collaborator

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)
}

@hjr3 hjr3 self-assigned this Apr 17, 2025
@hjr3
Copy link
Collaborator

hjr3 commented Apr 17, 2025

Closing this for now. Please re-open if my last response did not resolve your issue.

@hjr3 hjr3 closed this as completed Apr 17, 2025
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