porsager / porsager/postgres

Types for "infinite" connection timer options

Open
#1,178 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
8.7k
Forks
374
Avg merge
11d 16h
Merged PRs (30d)
1

Description

The connection timer options idle_timeout, max_lifetime, and connect_timeout support any falsy values for nullable timeouts via the timer() helper:

https://github.com/porsager/postgres/blob/e7dfa14519f363229ccc3ead7b1b2f2051937efb/src/connection.js#L1044-L1045

but the types are inconsistently declared as number or number | undefined then wrapped in Partial<> (effectively adding | undefined).

While it's true that using, e.g. connect_timeout: undefined would technically work with the current parseOptions use of k in o, it's potentially confusing with the defaulting logic when it's not present at all, so connect_timeout: 0 is currently the IMO best option to explicitly state you don't want a timeout, even if it's a bit weird looking.

It would be nice if other options like null or false were permitted, if this support is intentional? (Since this behavior isn't mentioned in the README that I could see)

Happy to PR if you think this is a good idea.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/connection.js around the timer() helper and parseOptions, then inspect the existing option type declarations for idle_timeout, max_lifetime, and connect_timeout. Determine whether null and false are intentionally supported; done means the declared types, runtime behavior, and any README explanation agree.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, postgresql
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.