porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.04k stars 257 forks source link

Connect-Timeout Behavior - Include Waiting for Connection Pool #824

Open nir-bar-zvi opened 3 months ago

nir-bar-zvi commented 3 months ago

We need our data-access code to be within a timeout. Currently, it seems the connect-timeout setting and behavior doesn't account for the time it takes for a connection to be avilable in the pool. Meaning, when the pool is exhausted, waiting for a connection when making a query can take longer than the connect-timeout setting. This causes our system to spiral out of control since we have automated request timeouts and retries. We don't want to increase the connection pool in this case and we prefer to fail the requests, and use the connect-timeout for that.

To summarize, we need a connection-timeout behavior that accounts for waiting for the pool to have a connection available. Do you have any guidance as to how we can achieve it?

azuker commented 3 months ago

Hi, I am in need of that too.

@porsager - First, thanks for all the work that was put into this, it's an awesome package and it does wonders for us. Regarding this issue, do you have any suggestion on how to approach this?