不要怂,就是干,撸起袖子干!

Commit 97c50bee by Daniel Durante

Postgres single connections will no longer leak

Some users were experiencing problems with Postgres connections leaking when
they didn't enable pooling. This commit should fix the problem.

- In prototype.disconnect() we now properly call this.client.end with
  this.client.end.bind(this.client) (as shown in the node-postgres wiki).
- We no longer check for readyForQuery on this.client as that value may not
  always be populated by node-postgres (possibly a bug on node-postgres).

This should close https://github.com/sequelize/sequelize/issues/859
1 parent 270ac753
Showing with 3 additions and 4 deletions
...@@ -116,7 +116,7 @@ module.exports = (function() { ...@@ -116,7 +116,7 @@ module.exports = (function() {
} else { } else {
done && done() done && done()
self.client = null self.client = null
emitter.emit('success', done) emitter.emit('success')
} }
} }
...@@ -124,7 +124,7 @@ module.exports = (function() { ...@@ -124,7 +124,7 @@ module.exports = (function() {
// acquire client from pool // acquire client from pool
this.pg.connect(uri, connectCallback) this.pg.connect(uri, connectCallback)
} else { } else {
if (!!this.client && this.client.readyForQuery === true) { if (!!this.client) {
connectCallback(null, this.client) connectCallback(null, this.client)
} else { } else {
//create one-off client //create one-off client
...@@ -142,10 +142,9 @@ module.exports = (function() { ...@@ -142,10 +142,9 @@ module.exports = (function() {
} }
if (this.client) { if (this.client) {
this.client.end() this.client.end.bind(this.client)
} }
this.client = null
this.isConnecting = false this.isConnecting = false
this.isConnected = false this.isConnected = false
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!