1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

fix: always emit an error when the connection drops

This commit is contained in:
Ruben Bridgewater
2017-05-30 04:38:02 +02:00
parent 265ce48af4
commit ac26d0524d
8 changed files with 42 additions and 36 deletions

View File

@ -78,17 +78,20 @@ function reconnect (client, why, error) {
timesConnected: client.timesConnected
})
if (typeof client.retryDelay !== 'number') {
// Pass individual error through
var err
if (client.retryDelay instanceof Error) {
error = client.retryDelay
}
flushAndError(client, 'Stream connection ended and command aborted.', 'NR_CLOSED', {
error
})
// TODO: Check if client is so smart
if (error) {
client.emit('error', error)
// Pass individual error through
err = client.retryDelay
flushAndError(client, 'Stream connection ended and command aborted.', 'NR_CLOSED', { error: err })
} else {
flushAndError(client, 'Stream connection ended and command aborted.', 'NR_CLOSED', { error })
err = new Errors.RedisError('Redis connection ended.')
err.code = 'NR_CLOSED'
if (error) {
err.origin = error
}
}
client.emit('error', err)
client.end(false)
return
}