Skip to content

unref setTimeout use in pg-pool #2078

Open
@gajus

Description

@gajus

In at least two cases, pg-pool creates a referenced timeout:

  1. tid = setTimeout(() => {
    this.log('remove idle client')
    this._remove(client)
    }, this.options.idleTimeoutMillis)
  2. const tid = setTimeout(() => {
    // remove the callback from pending waiters because
    // we're going to call it with a timeout error
    removeWhere(this._pendingQueue, (i) => i.callback === queueCallback)
    pendingItem.timedOut = true
    response.callback(new Error('timeout exceeded when trying to connect'))
    }, this.options.connectionTimeoutMillis)

These timeouts are currently keeping the process from dying naturally.

Use setTimeout().unref() to prevent this.

Unless I am overlooking a need to keep the pool awake?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions