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

Setting max: undefined results in only 1 connection being created #833

Open kieranm opened 3 months ago

kieranm commented 3 months ago

In our code we had an issue where we passed max: undefined when creating a Postgres instance, expecting that it would fall back to the default 10.

However, the undefined value seems to overwrite the default max: 10 due to this line: https://github.com/porsager/postgres/blob/master/src/index.js#L472

Then, due to this line, the array resolves to [undefined] and therefore only a single connection will be created. https://github.com/porsager/postgres/blob/master/src/index.js#L65

If max: undefined is passed then perhaps the default 10 needs to take precedence.