mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Fix queued checkout after a connection failure (#111)
* Test queued checkout after a connection failure Co-authored-by: Johannes Würbach <johannes.wuerbach@googlemail.com> * Fix queued checkout after a connection failure Co-authored-by: Johannes Würbach <johannes.wuerbach@googlemail.com>
This commit is contained in:
parent
4b9669eaa7
commit
7ef3f4aa4a
4
index.js
4
index.js
@ -226,6 +226,10 @@ class Pool extends EventEmitter {
|
||||
if (timeoutHit) {
|
||||
err.message = 'Connection terminated due to connection timeout'
|
||||
}
|
||||
|
||||
// this client won’t be released, so move on immediately
|
||||
this._pulseQueue()
|
||||
|
||||
cb(err, undefined, NOOP)
|
||||
} else {
|
||||
this.log('new client connected')
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
'use strict'
|
||||
const net = require('net')
|
||||
const co = require('co')
|
||||
const expect = require('expect.js')
|
||||
|
||||
@ -143,4 +144,25 @@ describe('pool error handling', function () {
|
||||
return pool.end()
|
||||
}))
|
||||
})
|
||||
|
||||
it('should continue with queued items after a connection failure', (done) => {
|
||||
const closeServer = net.createServer((socket) => {
|
||||
socket.destroy()
|
||||
}).unref()
|
||||
|
||||
closeServer.listen(() => {
|
||||
const pool = new Pool({ max: 1, port: closeServer.address().port })
|
||||
pool.connect((err) => {
|
||||
expect(err).to.be.an(Error)
|
||||
expect(err.message).to.be('Connection terminated unexpectedly')
|
||||
})
|
||||
pool.connect((err) => {
|
||||
expect(err).to.be.an(Error)
|
||||
expect(err.message).to.be('Connection terminated unexpectedly')
|
||||
closeServer.close(() => {
|
||||
pool.end(done)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user