Skip to content

client.end() no longer releases connection back into pool in v5.2.1 #1414

Closed
@watson

Description

@watson

The previous latest 5.x version was 5.1.0 which used an internal pool object (here's a diff). In 5.2.1, which was released a few days ago, this was replaced with pg-pool.

Here's a test which you can run on 5.1.0 and it passes, but it fails if on 5.2.1 where it will never end because the pg.connect callback isn't called after 10 connections have been opened:

var pg = require('pg')

var conString = 'postgres://localhost/<PUT-DATABASE-NAME-HERE>'
var n = 0

setInterval(function () {
  var nn = ++n
  console.log('start', nn)

  pg.connect(conString, function (err, client, done) {
    if (err) throw err
    console.log('done', nn)
    client.end()
    if (nn > 10) {
      console.log('success!')
      process.exit()
    }
  })
}, 100)

If I instead of client.end() call done(), then it works as expected. But calling client.end() used to work before the v5.2.1 release.

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