Skip to content

Types for "infinite" connection timer options #1178

Description

@simonbuchan

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

postgres/src/connection.js

Lines 1044 to 1045 in e7dfa14

if (!seconds)
return { cancel: noop, start: noop }

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions