Skip to content

PostgresJS Prevents Natural Process Exit #869

@granthusbands

Description

@granthusbands

On Node, if PostgresJS has been used at all, the process won't exit naturally, as it has some number of pooled connections still open. It seems that people are expected to call sql.end() or set a low connection timeout. However, I think there's a simpler solution for end users. If PostgresJS can call soc.unref() on idle connections entering the pool and call soc.ref() when they're taken back out of the pool, the idle connections will no longer keep the process alive.

To be clear, unref() tells node that the socket is not important enough to keep the process alive, and ref() tells it that the socket is again important enough. The documentation implies that it's a toggle, rather than a counter, so it should be low risk. Also note that it's probable that some timers (for idle timeout and such) will also need unref called on the object returned from setTimeout or setInterval. They can probably just stay unref.

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