Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we document Pool.ending property? #73

Open
mriedem opened this issue Apr 24, 2020 · 0 comments
Open

Can we document Pool.ending property? #73

mriedem opened this issue Apr 24, 2020 · 0 comments

Comments

@mriedem
Copy link
Contributor

mriedem commented Apr 24, 2020

I wasn't sure if Pool.ending can be used externally but if so can we document it here?

https://github.com/brianc/node-postgres-docs/blob/master/content/api/1-pool.mdx#properties

Per https://node-postgres.com/api/pool#pool.end I use express-graceful-exit with a callback that calls Pool.end() but only if the pool's ending value is false, e.g.:

function shutdown (app, server, exitCode = 0) {
  gracefulShutdown(app, server, exitCode > 0 ? 'error' : 'info', () => {
    try {
      if (!pgPool.ending) {
        log.info(`Shutting down DB connection pool; waiting: ${pgPool.waitingCount}, idle: ${pgPool.idleCount}`)
        pgPool.end(error => {
          if (error) throw error
        })
      }
    } catch (err) {
      log.error(err, 'An error occurred while shutting down the DB connection pool.')
    } finally {
      setTimeout(() => process.exit(exitCode), 2000)
    }
  })
}

Using pgPool.ending means I don't need to track that myself but I'm unsure if it's a "supported" property to rely on outside of the Pool object itself. If it is, can we document it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant