mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
Don't repeat logic for reporting stream errors
This commit is contained in:
parent
4cf67b23d4
commit
70a8ee1334
@ -62,14 +62,15 @@ Connection.prototype.connect = function (port, host) {
|
||||
self.emit('connect')
|
||||
})
|
||||
|
||||
this.stream.on('error', function (error) {
|
||||
const reportStreamError = function (error) {
|
||||
// don't raise ECONNRESET errors - they can & should be ignored
|
||||
// during disconnect
|
||||
if (self._ending && error.code === 'ECONNRESET') {
|
||||
return
|
||||
}
|
||||
self.emit('error', error)
|
||||
})
|
||||
}
|
||||
this.stream.on('error', reportStreamError)
|
||||
|
||||
this.stream.on('close', function () {
|
||||
self.emit('end')
|
||||
@ -97,15 +98,7 @@ Connection.prototype.connect = function (port, host) {
|
||||
NPNProtocols: self.ssl.NPNProtocols
|
||||
})
|
||||
self.attachListeners(self.stream)
|
||||
|
||||
self.stream.on('error', function (error) {
|
||||
// don't raise ECONNRESET errors - they can & should be ignored
|
||||
// during disconnect
|
||||
if (self._ending && error.code === 'ECONNRESET') {
|
||||
return
|
||||
}
|
||||
self.emit('error', error)
|
||||
})
|
||||
self.stream.on('error', reportStreamError)
|
||||
|
||||
self.emit('sslconnect')
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user