Firebase Update
This commit is contained in:
31
express-server/node_modules/pg-pool/index.js
generated
vendored
31
express-server/node_modules/pg-pool/index.js
generated
vendored
@ -3,6 +3,14 @@ const EventEmitter = require('events').EventEmitter
|
||||
|
||||
const NOOP = function () { }
|
||||
|
||||
const remove = (list, value) => {
|
||||
const i = list.indexOf(value)
|
||||
|
||||
if (i !== -1) {
|
||||
list.splice(i, 1)
|
||||
}
|
||||
}
|
||||
|
||||
const removeWhere = (list, predicate) => {
|
||||
const i = list.findIndex(predicate)
|
||||
|
||||
@ -157,18 +165,20 @@ class Pool extends EventEmitter {
|
||||
return result
|
||||
}
|
||||
|
||||
const queueCallback = (err, res, done) => {
|
||||
clearTimeout(tid)
|
||||
response.callback(err, res, done)
|
||||
}
|
||||
|
||||
// set connection timeout on checking out an existing client
|
||||
const tid = setTimeout(() => {
|
||||
// remove the callback from pending waiters because
|
||||
// we're going to call it with a timeout error
|
||||
this._pendingQueue = this._pendingQueue.filter(cb => cb === response.callback)
|
||||
remove(this._pendingQueue, queueCallback)
|
||||
response.callback(new Error('timeout exceeded when trying to connect'))
|
||||
}, this.options.connectionTimeoutMillis)
|
||||
|
||||
this._pendingQueue.push(function (err, res, done) {
|
||||
clearTimeout(tid)
|
||||
response.callback(err, res, done)
|
||||
})
|
||||
this._pendingQueue.push(queueCallback)
|
||||
return result
|
||||
}
|
||||
|
||||
@ -186,7 +196,7 @@ class Pool extends EventEmitter {
|
||||
this.emit('error', err, client)
|
||||
}
|
||||
|
||||
this.log('connecting new client')
|
||||
this.log('checking client timeout')
|
||||
|
||||
// connection timeout logic
|
||||
let tid
|
||||
@ -205,19 +215,24 @@ class Pool extends EventEmitter {
|
||||
|
||||
this.log('connecting new client')
|
||||
client.connect((err) => {
|
||||
this.log('new client connected')
|
||||
if (tid) {
|
||||
clearTimeout(tid)
|
||||
}
|
||||
client.on('error', idleListener)
|
||||
if (err) {
|
||||
this.log('client failed to connect', err)
|
||||
// remove the dead client from our list of clients
|
||||
this._clients = this._clients.filter(c => c !== client)
|
||||
if (timeoutHit) {
|
||||
err.message = 'Connection terminiated due to connection timeout'
|
||||
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')
|
||||
client.release = release.bind(this, client)
|
||||
this.emit('connect', client)
|
||||
this.emit('acquire', client)
|
||||
|
Reference in New Issue
Block a user